Gert Vanthienen's blog

Saturday, July 3, 2010

Camel async routing in ServiceMix

Until recently, servicemix-camel did not allow asynchronous interaction with the NMR. Every MessageExchange was being sent using sendSync(), causing the calling thread to wait for the MessageExchange to finish.

Let's take a look at this set of Camel routes:

from("jbi:endpoint:urn:test:service:endpoint1")
.to(""jbi:endpoint:urn:test:service:endpoint2");
from("jbi:endpoint:urn:test:service:endpoint2")
.to(""jbi:endpoint:urn:test:service:endpoint3");
from("jbi:endpoint:urn:test:service:endpoint3")
.to(""jbi:endpoint:urn:test:another_service:endpoint");


When sending an exchange to endpoint 1, the diagram below shows how this invocation will cause three threads to be waiting until the entire flow ends.


For the upcoming Camel 2.4.0 release, Claus Ibsen has been working hard to add fully async routing to Camel again. The servicemix-camel and camel-nmr components have already been upgraded to leverage his hard work, because this improvement completely changes the picture for JBI and NMR integration.

As you can see below, the threads are now no longer waiting, but are available to pick up new work while the initial flow of MessageExchanges is still ongoing.


If you're using Camel inside ServiceMix, make sure you pick up the next version of Apache ServiceMix or FUSE ESB to benefit from these scalability improvements.