camel-users mailing list archives

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

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 <> 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:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:
Make your Camel applications look hawt, try:

View raw message