Try splitting up routes more and using ActiveMQ or another broker in between the routes. So instead of "waiting for the message to arrive" consume the message with a route and resume programming perhaps enriching with other messages from other sources. You can also create an aggregation strategy that will aggregate messages and only complete the aggregation after M2 arrives. Then its up to you what the output of the aggregator is. This can be more risky in parallel processing with concurrent consumers since you cant be sure which of the concurrent consumers will consume the method.
Thinking about suspending and waiting in a route is a synchrous mindset, think more asynch using signals and aggregation rather than waiting, calling and replying. *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 <http://www.linkedin.com/pub/robert-simmons/40/852/a39>* On Thu, Jan 2, 2014 at 9:39 AM, Richard Kettelerij < [email protected]> wrote: > >> Step 2 implies that the message coming on Q2 needs to be inspected and > only if it turns out to be M2..... > > I think the Content-Based Router EIP is a good fit here, > http://camel.apache.org/content-based-router.html. For example: > > from("jms:q2") > .choice().when(body().isInstanceOf(M2.class)) > .to("controlbus:routeId=Route1&action=start") > .end() > > >> Is there something we can do to pause a Route while it waits for a > message and resume it once the message arrives? > > If a route is paused it cannot do anything, its paused after all. You'll > need another route or process to resume a route. Pausing/resuming routes > can be done using the CamelContext ( > http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html) or using > the ControlBus EIP (http://camel.apache.org/controlbus.html). The latter > is > easier to use, as illustrated in the code sample above. > > >> Can we raise an event so that any Route that is waiting for M2 can be > resumed? > >> What do we need to do to resume the route? > > Use the CamelContext API directly or use the ControlBus EIP as I mentioned > > Regards, > Richard > > > > On Tue, Dec 31, 2013 at 5:56 PM, yashgt <[email protected]> wrote: > > > Hi, > > > > Route1: > > Send Message M1 to MQ Q1. // This message goes to a program that > > consumes > > from Q1 and once some processing is done, write message M2 to Q2. > > Upon receiving Message M2 on Q2, //Q2 receives several messages > > (M2,N2,P2, > > etc.). ONLY when M2 is received, the Route1 should continue. > > Send message M3 to Q3. // The step should be executed only > > > > Step 2 implies that the message coming on Q2 needs to be inspected and > only > > if it turns out to be M2, the Route1 should resume. Is there something we > > can do to pause a Route while it waits for a message and resume it once > the > > message arrives? > > Can we raise an event so that any Route that is waiting for M2 can be > > resumed? We know for sure that among all the parallely executing routes, > > only one may wait for M2. What do we need to do to resume the route? > > > > Thanks, > > Yash > > > > > > > > -- > > View this message in context: > > > http://camel.465427.n5.nabble.com/Asynchronous-processing-of-routes-tp5745385.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > >
