...
Wiki Markup |
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| {{asyncDelayed}} | {{false}} | *Camel 2.4:* If enabled then delayed messages happens asynchronously using a scheduled thread pool. |
| {{executorServiceRef}} | | *Camel 2.4:* Refers to a custom [Thread Pool|Threading Model] to be used if {{asyncDelay}} has been enabled. |
| {{callerRunsWhenRejected}} | {{true}} | *Camel 2.4:* Is used if {{asyncDelayed}} was enabled. This controls if the caller thread should execute the task if the thread pool rejected the task. |
{div} |
Using the Fluent Builders
The example below will delay all messages received on seda:b 1 second before sending them to mock:result.
Wiki Markup |
{snippet:id=ex2|lang=java|url=""> |
So the above example will delay all messages received on seda:b 1 second before sending them to mock:result.
You can of course use many different _expression_ languages such as XPath, XQuery, SQL or various Scripting Languages. You can
You can just delay things a fixed amount of time from the point at which the delayer receives the message. For example to delay things 2 seconds
Code Block |
delayer(2000)
|
The above assume that the delivery order is maintained and that the messages are delivered in delay order. If you want to reorder the messages based on delivery time, you can use the Resequencer with this pattern. For example
Code Block |
from("activemq:someQueue").resequencer(header("MyDeliveryTime")).delay("MyRedeliveryTime").to("activemq:aDelayedQueue");
|
You can of course 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:
Code Block |
from("activemq:someQueue").delay(header("delayValue")).to("activemq:aDelayedQueue");
|
And to delay processing using the Simple language you can use the following DSL:
Code Block |
from("activemq:someQueue").delay(simple("${body.delayProperty}")).to("activemq:aDelayedQueue");
|
Spring DSL
The sample below demonstrates the delay in Spring DSL:
...
You use the asyncDelayed() to enable the async behavior.
Code Block |
from("activemq:queue:foo").delay(1000).asyncDelayed().to("activemq:aDelayedQueue");
|
...
You use the asyncDelayed="true" attribute to enable the async behavior.
Code Block |
|
|
<route>
<from uri="activemq:queue:foo"/>
<delay asyncDelayed="true">
<constant>1000</constant>
</delay>
<to uri="activemq:aDealyedQueue"/>
</route>
|
...
You can use an _expression_ to determine when to send a message using something like this
Code Block |
from("activemq:foo").
delay().method("someBean", "computeDelay").
to("activemq:bar");
|
then the bean would look like this...
Code Block |
public class SomeBean {
public long computeDelay() {
long delay = 0;
// use java code to compute a delay value in millis
return delay;
}
}
|
Include Page |
|
|
See Also