Architecture

Delayer

qianmoQqianmoQ· 更新于 2026-09-23· 阅读 4 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

Delayer

The Delayer is used for slowing processing of messages.

This allows you to set a fixed amount of delay between each step a message passes in the route. It can be used to better show how things are happening nicely and slowly, so you are not bombarded with a zillion lines of logging output.

Using Delayer

The delayer can be configured on two levels:

  • Camel context: Globally
  • Route: Individually per route

Configuring using Spring XML

Set the delayer attribute of the <camelContext> tag as shown below:

Spring XML

<camelContext id="camel" delayer="500" xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="direct:start"/>
        <to uri="mock:result"/>
    </route>
</camelContext>

Configuring using Java

You can enable delaying messages by setting the delay value on the CamelContext as shown:

camelContext.setDelayer(200);

Configuring on route level

You can also configure it on both camel context and per route as you like. Per route will override the camel context setting.

For example, the route below is only the first route that has a delayer with 200 milliseconds.

  • Java
  • XML
  • YAML
from("direct:start").delayer(200)
    .to("mock:result")
<route delayer="200">
 ...
</route>

<route>
 ...
</route>
- route:
    delayer: 200
    from:
      uri: direct:start
      steps:
        - to:
            uri: mock:result

评论

登录后参与评论

正在加载评论…