Delayer (Interceptor)
The Delayer (Interceptor) is an route interceptor that is used for slowing processing of messages down. This allows you to enable this interceptor and set a fixed amount of delay between each step a message passes in the route path, to show how things is happening nice and slowly, so you are not bombarded with a zillion lines of logging output.
The delay interceptor can be configured as follows:
- using Java system property
camel.delay=value
where value is the fixed delay in millis. - setting the delay attribute in the spring camelContext tag.
- adding the delay interceptor to the CamelContext in Java code.
Configuring as system property
You can set the delay as a JVM system property as:
Code Block |
---|
-Dcamel.delay=500
|
Where we set the delay to 500 millis.
Configuring using Spring
Just set the delay attribute of the camelContext tag as shown below:
Code Block | ||||
---|---|---|---|---|
| ||||
<camelContext id="camel" delay="500" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="direct:start"/>
<to uri="mock:result"/>
</route>
</camelContext>
|
Configuring using Java
You can add the delayer interceptor in the RouteBulder as shown below:
Code Block | ||||
---|---|---|---|---|
| ||||
public void configure() throws Exception {
// add the delay interceptor to delay each step 200 millis
getContext().addInterceptStrategy(new Delayer(200));
... // regular routes here
}
|
See Also
...