You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Pa...@t-systems.com on 2024/09/19 13:10:56 UTC

Dynamic To with InOnly Exchange Pattern in Java DSL

Hi,

is there a way to use dynamic to with InOnly Exchange Pattern from the Java DSL?

https://camel.apache.org/components/4.8.x/eips/toD-eip.html#_options mentions a pattern option, but I cannot find a way to use it.

While there is #to(ExchangePattern pattern, String uri) I was not able to find a #toD variant that accepts an ExchangePattern parameter.

I was not able to find an EndpointBuilder either.

I tried

.toD(new ToDynamicDefinition("jms:${exchangeProperty.queueName}").pattern(ExchangePattern.InOnly).getEndpointProducerBuilder())

But that resulted in:

org.apache.camel.FailedToCreateRouteException: Failed to create route ...
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:235)
	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:86)
	at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:726)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:592)
	at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2429)
	at org.apache.camel.support.service.BaseService.init(BaseService.java:85)
	at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2064)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2083)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:211)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121)
	at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:153)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:452)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:385)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:993)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:628)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
...
Caused by: java.lang.IllegalArgumentException: uri must be specified and not empty on: mailto:org.apache.camel.reifier.ToDynamicReifier@3d70a045
	at org.apache.camel.util.StringHelper.notEmpty(StringHelper.java:376)
...

What am I missing?

Thanks and kind regards,
Pascal

AW: Dynamic To with InOnly Exchange Pattern in Java DSL

Posted by Pa...@t-systems.com.
Thank you very much Claus and Raymond. I did know this method and wasn't able to google the answer.

-----Ursprüngliche Nachricht-----
Von: ski n <ra...@gmail.com>
Gesendet: Donnerstag, 19. September 2024 16:11
An: users@camel.apache.org
Betreff: Re: Dynamic To with InOnly Exchange Pattern in Java DSL

Like Claus mentioned, it's always possible to set the exchangePattern into a separate step. A route would look something like this:

        from("direct:start")
            .setExchangePattern(ExchangePattern.InOnly)
            .toD("log:${header.destination}");

Raymond

On Thu, Sep 19, 2024 at 3:58 PM Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> You can use setExchangePattern before the toD
>
> On Thu, Sep 19, 2024 at 3:11 PM <Pa...@t-systems.com> wrote:
>
> > Hi,
> >
> > is there a way to use dynamic to with InOnly Exchange Pattern from
> > the Java DSL?
> >
> > https://ca/
> > mel.apache.org%2Fcomponents%2F4.8.x%2Feips%2FtoD-eip.html%23_options
> > &data=05%7C02%7CPascal.Schumacher%40t-systems.com%7C0a6b7fe146c94de4
> > bc8f08dcd8b4feef%7Cbde4dffc4b604cf68b04a5eeb25f5c4f%7C0%7C0%7C638623
> > 519098585887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l
> > uMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=3UsnqD6u85vq0
> > jurkzY6n4Z5KDY%2FIJRk4paM97Qv1eI%3D&reserved=0
> > mentions a pattern option, but I cannot find a way to use it.
> >
> > While there is #to(ExchangePattern pattern, String uri) I was not
> > able to find a #toD variant that accepts an ExchangePattern parameter.
> >
> > I was not able to find an EndpointBuilder either.
> >
> > I tried
> >
> > .toD(new
> >
> ToDynamicDefinition("jms:${exchangeProperty.queueName}").pattern(Excha
> ngePattern.InOnly).getEndpointProducerBuilder())
> >
> > But that resulted in:
> >
> > org.apache.camel.FailedToCreateRouteException: Failed to create route ...
> >         at
> >
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:
> 235)
> >         at
> > org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:86)
> >         at
> >
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultMo
> delReifierFactory.java:49)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(Defaul
> tCamelContext.java:726)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(Defaul
> tCamelContext.java:592)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamel
> Context.java:2429)
> >         at
> > org.apache.camel.support.service.BaseService.init(BaseService.java:85)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelCo
> ntext.java:2064)
> >         at
> > org.apache.camel.support.service.BaseService.start(BaseService.java:115)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelC
> ontext.java:2083)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.ja
> va:211)
> >         at
> >
> org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.ja
> va:121)
> >         at
> >
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCa
> melContext.java:153)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.do
> InvokeListener(SimpleApplicationEventMulticaster.java:185)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.in
> vokeListener(SimpleApplicationEventMulticaster.java:178)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.mu
> lticastEvent(SimpleApplicationEventMulticaster.java:156)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.publish
> Event(AbstractApplicationContext.java:452)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.publish
> Event(AbstractApplicationContext.java:385)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.finishR
> efresh(AbstractApplicationContext.java:993)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.refresh
> (AbstractApplicationContext.java:628)
> >         at
> >
> org.springframework.boot.web.servlet.context.ServletWebServerApplicati
> onContext.refresh(ServletWebServerApplicationContext.java:146)
> >         at
> >
> org.springframework.boot.SpringApplication.refresh(SpringApplication.j
> ava:754)
> >         at
> >
> org.springframework.boot.SpringApplication.refreshContext(SpringApplic
> ation.java:456)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:
> 335)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:
> 1363)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:
> 1352)
> > ...
> > Caused by: java.lang.IllegalArgumentException: uri must be specified
> > and not empty on: mailto:org.apache.camel.reifier.ToDynamicReifier@3d70a045
> >         at
> > org.apache.camel.util.StringHelper.notEmpty(StringHelper.java:376)
> > ...
> >
> > What am I missing?
> >
> > Thanks and kind regards,
> > Pascal
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2:
> https://www.manning.com/ibsen2
>

Re: Dynamic To with InOnly Exchange Pattern in Java DSL

Posted by ski n <ra...@gmail.com>.
Like Claus mentioned, it's always possible to set the exchangePattern into
a separate step. A route would look something like this:

        from("direct:start")
            .setExchangePattern(ExchangePattern.InOnly)
            .toD("log:${header.destination}");

Raymond

On Thu, Sep 19, 2024 at 3:58 PM Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> You can use setExchangePattern before the toD
>
> On Thu, Sep 19, 2024 at 3:11 PM <Pa...@t-systems.com> wrote:
>
> > Hi,
> >
> > is there a way to use dynamic to with InOnly Exchange Pattern from the
> > Java DSL?
> >
> > https://camel.apache.org/components/4.8.x/eips/toD-eip.html#_options
> > mentions a pattern option, but I cannot find a way to use it.
> >
> > While there is #to(ExchangePattern pattern, String uri) I was not able to
> > find a #toD variant that accepts an ExchangePattern parameter.
> >
> > I was not able to find an EndpointBuilder either.
> >
> > I tried
> >
> > .toD(new
> >
> ToDynamicDefinition("jms:${exchangeProperty.queueName}").pattern(ExchangePattern.InOnly).getEndpointProducerBuilder())
> >
> > But that resulted in:
> >
> > org.apache.camel.FailedToCreateRouteException: Failed to create route ...
> >         at
> >
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:235)
> >         at
> > org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:86)
> >         at
> >
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:726)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:592)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2429)
> >         at
> > org.apache.camel.support.service.BaseService.init(BaseService.java:85)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2064)
> >         at
> > org.apache.camel.support.service.BaseService.start(BaseService.java:115)
> >         at
> >
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2083)
> >         at
> >
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:211)
> >         at
> >
> org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121)
> >         at
> >
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:153)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
> >         at
> >
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:452)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:385)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:993)
> >         at
> >
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:628)
> >         at
> >
> org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
> >         at
> >
> org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
> >         at
> >
> org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
> >         at
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
> > ...
> > Caused by: java.lang.IllegalArgumentException: uri must be specified and
> > not empty on: mailto:org.apache.camel.reifier.ToDynamicReifier@3d70a045
> >         at
> > org.apache.camel.util.StringHelper.notEmpty(StringHelper.java:376)
> > ...
> >
> > What am I missing?
> >
> > Thanks and kind regards,
> > Pascal
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Dynamic To with InOnly Exchange Pattern in Java DSL

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can use setExchangePattern before the toD

On Thu, Sep 19, 2024 at 3:11 PM <Pa...@t-systems.com> wrote:

> Hi,
>
> is there a way to use dynamic to with InOnly Exchange Pattern from the
> Java DSL?
>
> https://camel.apache.org/components/4.8.x/eips/toD-eip.html#_options
> mentions a pattern option, but I cannot find a way to use it.
>
> While there is #to(ExchangePattern pattern, String uri) I was not able to
> find a #toD variant that accepts an ExchangePattern parameter.
>
> I was not able to find an EndpointBuilder either.
>
> I tried
>
> .toD(new
> ToDynamicDefinition("jms:${exchangeProperty.queueName}").pattern(ExchangePattern.InOnly).getEndpointProducerBuilder())
>
> But that resulted in:
>
> org.apache.camel.FailedToCreateRouteException: Failed to create route ...
>         at
> org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:235)
>         at
> org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:86)
>         at
> org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:726)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:592)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2429)
>         at
> org.apache.camel.support.service.BaseService.init(BaseService.java:85)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2064)
>         at
> org.apache.camel.support.service.BaseService.start(BaseService.java:115)
>         at
> org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2083)
>         at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:211)
>         at
> org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121)
>         at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:153)
>         at
> org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
>         at
> org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
>         at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
>         at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:452)
>         at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:385)
>         at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:993)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:628)
>         at
> org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
>         at
> org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
>         at
> org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
>         at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
>         at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
>         at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
> ...
> Caused by: java.lang.IllegalArgumentException: uri must be specified and
> not empty on: mailto:org.apache.camel.reifier.ToDynamicReifier@3d70a045
>         at
> org.apache.camel.util.StringHelper.notEmpty(StringHelper.java:376)
> ...
>
> What am I missing?
>
> Thanks and kind regards,
> Pascal
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2