Yash
Yash

Reputation: 1018

Asynchronous processing of routes in Camel

Route1:

1. 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.<br/>

2. Upon receiving Message M2 on Q2, //Q2 receives several messages (M2,N2,P2, etc.). ONLY when M2 is received, the Route1 should continue.<br/>

3. Send message M3 to Q3. // The step should be executed only after step 2 is complete<br/>

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

Upvotes: 0

Views: 680

Answers (1)

Ben ODay
Ben ODay

Reputation: 21015

there are a couple of options for controlling routes at runtime

  • use a RoutePolicy to add route lifecycle callbacks
  • use content based routing to apply specific logic based on message attributes/content
  • use the aggregator to group messages together based on various rules, etc.
  • use the ControlBus component to control routes status

also see this page for how to stop a route from another route

Upvotes: 2

Related Questions