第 12 章 系统管理

摘要

系统管理模式描述了如何监控、测试和管理消息传递系统。

12.1. detour

detour

如果满足控制条件,可以通过 第 3 章 企业级集成模式简介 取消使用额外的步骤来发送信息。http://www.enterpriseintegrationpatterns.com/Detour.html它可用于在需要时打开额外的验证、测试、调试代码。

detour

示例

在本例中,我们本质上有一个 来自("direct:start").to("mock:result") 的路由,其有条件 指示到路由中间的模拟:detour 端点。

from("direct:start").choice()
    .when().method("controlBean", "isDetour").to("mock:detour").end()
    .to("mock:result");

使用 Spring XML 扩展

<route>
  <from uri="direct:start"/>
    <choice>
      <when>
        <method bean="controlBean" method="isDetour"/>
	<to uri="mock:detour"/>
      </when>
    </choice>
    <to uri="mock:result"/>
  </split>
</route>

债务部是否由 ControlBean 决定。因此,当消息上路由到 模拟:detour, 然后 模拟结果。当 detour 被关闭时,消息会被路由到 模拟:result

有关详情请查看示例源:

camel-core/src/test/java/org/apache/camel/processor/DetourTest.java