camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Novák>
Subject Combining patterns
Date Tue, 18 Sep 2007 12:56:27 GMT
Hello, I have a quite basic problem which I cannot solve. The thing is 
that I want to send message to couple of services. These services should 
be invoked from multiple threads because the processing will take quite 
some time. Then I want to gather, and aggregate the output of the 
services somehow nicely, and return it to the calling point.

I was trying to use seda with combination with aggregator, which worked 
up to the point that it returned just the first message to the user - 
before aggregator was able to process the rest. I know that the whole 
service is asynchronous by my design, but it would be nice to know how 
to gather the results back...

there is an excerpt from my code - just an illustation:

from("direct:a").setHeader("splitCount", new Expression() {
public Object evaluate(Exchange exchange) {
   return 2;
}}).to("seda:b", "seda:c");
from("seda:b").process(new HeaderSetter("msgCounter", 
from("seda:c").process(new HeaderSetter("msgCounter", 

Exchange exchange = new DefaultExchange(ctx);
exchange.getIn().setBody("<result" + ii + " />");
exchange.getIn().setHeader("msgId", "ahojValue" + ii);
exchange = template.send("direct:a", exchange);
Object body = exchange.getOut().getBody();

can somebody advice me what to do please?

View raw message