Hello everyone
I have tried to test the parallel processing with Camel. The split was easy
and worked out of the box. I have some surprises and I'm wondering whenever
I'm understanding correctly the expected behaviour with the multicast. In
the Code below, I try to send messages to two routes. The "even" route takes
more time than the "odd" one. I would like to get the odd number I'm sending
before the even number. I was expecting the odd number to be processed
faster than the other, am I correct?
I'm currently getting the exchange in the same order I sent, is it the
expected behavior?
Thanks and have a nice day
Christophe
I'm using camel 2.12:
val croute = new org.apache.camel.builder.RouteBuilder {
override def configure(): Unit = {
from("direct:input").multicast().parallelProcessing().
to("direct:even", "direct:odd").end()
from("direct:odd").filter(body.isEqualTo(1)).process(new Processor
{
override def process(exchange: Exchange): Unit = {
println(exchange.getIn.getBody)
}
}).to("mock:output")
from("direct:even").filter(body.isEqualTo(0)).
process(new Processor {
override def process(exchange: Exchange): Unit = {
println(exchange.getIn.getBody)
Thread.sleep(1000)
//or to avoid side effects on the Thread: (1 to
1000000).foreach(x => scala.util.Random.nextDouble())
}
}
).
to("mock:output")
}
}
//.....
val producer = camelContext.createProducerTemplate()
List(0, 1, 0, 1, 0, 1, 0, 1, 0, 1).foreach(x =>
producer.sendBody("direct:input", x))
--
View this message in context:
http://camel.465427.n5.nabble.com/parallelProcessing-with-multicast-tp5765146.html
Sent from the Camel - Users mailing list archive at Nabble.com.