camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: How to programmatically find next downstream endpoint in a route.
Date Fri, 04 Oct 2013 17:38:26 GMT
Does a splitter not work for you in this case?

On Fri, Oct 4, 2013 at 1:28 PM, Chris <cwolf.algo@gmail.com> wrote:
> Hello,
>
> I implemented a bean whose method accepts an exchange with a single message,
> then generates multiple messages intended for the next endpoint down-stream,
> along the lines of this:
>
> http://camel.apache.org/how-do-i-write-a-custom-processor-which-sends-multiple-messages.html
>
>
> However, I'd like to avoid having to explicitly configure the endpoint in
> the bean's ProducerTemplate if it can be found in the route definition.
>
> In other words, if I have:
>
> from("direct:start")
> .enrich("bean:MyBean")
> .to("mock:result");  <<< this should be sufficient to indicate producer
> target URI.
>
> ...and MyBean is:
>
> public MyBean {
>   protected ProducerTemplate producer;
>   public void businessLogic(Exchange exchange) {
>       if (producer == null) {
>           producer = exchange.createProducerTemplate();
>           producer.setDefaultEndpointUri("mock:result"); <<< Why should I
> have to do this?  I just want it to go to the next down-stream endpoint in
> the pipeline, already defined in the route!!<<<<
>       }
>       [...bla, bla, bla...]
>       while (hasStuffToSend) {
>           producer.setBody(stuff[i]);
>       }
>   }
> }
>
>

Mime
View raw message