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 <[email protected]> wrote:
> Hi
>
> You can use setExchangePattern before the toD
>
> On Thu, Sep 19, 2024 at 3:11 PM <[email protected]> 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
>