camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manishk <manish.ka...@gmail.com>
Subject spawning exchanges from the processor
Date Fri, 21 Mar 2014 16:50:04 GMT
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.

Mime
View raw message