camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: spawning exchanges from the processor
Date Sat, 22 Mar 2014 07:14:37 GMT
Hi

You likely have a bug in your custom code. Sounds like you need to
create a new fromList instance for each exchange so they do not refer
and use a shared list.

On Fri, Mar 21, 2014 at 5:50 PM, manishk <manish.karki@gmail.com> wrote:
> Hello, I am new to camel and have just started working on a integration
> project.
> The scenario i have is as follows,
> i receive a message on an endpoint, pass it to a Processor. The processor
> iterates over a List(contains a collection of a specific attribute to be set
> in the message) and sets an attribute of the message each time and sends the
> exchange to another endpoint.
> I see that the exchanges are getting spawned from the Processor but the
> problem is that all the messages received contain the same value of the
> attribute set from the List. Example, if List has values
> ("targetA","targetB") and i iterate over this and set the message and the
> send it to my endpoint,
> I receive two messages but both have the same target set i.e "targetA".
>
>
> Below is the code snippet of the processor
> @Override
>     public void process(Exchange exchange) throws Exception {
>         MyMessage myMessage = exchange.getIn().getBody(MyMessage.class);
>         {//iterate over the collection
>
>        //do some processing
>        myMessage.setTarget(fromList);
>         Exchange newExchange = new DefaultExchange(exchange.getContext());
>         newExchange.getIn().setBody(myMessage, MyMessage.class);
>         newExchange.getIn().setHeader("target", fromList);
>         exchange.getContext().createProducerTemplate()
>                             .send("seda:processResults", newExchange);
>          }
> }
>
> PS: the header i set does not have the same issue.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/spawning-exchanges-from-the-processor-tp5749208.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Mime
View raw message