Dynamically delaying processing of the Camel route
Environment
- JBoss Fuse 6.0
Issue
I would like to delay the processing of the message in Camel route. The suspension value should be read dynamically from the incoming message.
Resolution
The recommended approach to suspend processing of the message for the time period calculated from the incoming messages is to use Delayer [1] EIP. You can use many different Expression languages such as XPath, XQuery, SQL or various Scripting Languages.
For example to delay the message for the time period specified in the header, use the following syntax:
from("activemq:someQueue").delay(header("delayValue")).to("activemq:aDelayedQueue");
And to delay processing using the Simple [2] language you can use the following DSL:
from("activemq:someQueue").delay(simple("${body.delayProperty}")).to("activemq:aDelayedQueue");
[1] http://camel.apache.org/delayer.html
[2]http://camel.apache.org/simple.html
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
