camel系列-多通道

MULTICAST

EIP 允许将相同的消息路由到多个端点并以不同的方式处理它们。

1
2
3
4
5
6
7
8
<route>
<from uri="direct:a"/>
<multicast>
<to uri="direct:b"/>
<to uri="direct:c"/>
<to uri="direct:d"/>
</multicast>
</route>

注意点:

在路由端点执行之前,Exchange 会先进行一次浅拷贝,如下需要深拷贝定制的话,需要自定义实现 onPrepare 方法

PipeLine

1
2
3
4
5
6
7
8
<route>
<from uri="activemq:cheese"/>
<pipeline>
<to uri="bean:foo"/>
<to uri="bean:bar"/>
<to uri="activemq:wine"/>
</pipeline>
</route>

跟 MULTICAST 类似,但每次路由传递的都是相同的消息,而非消息的副本.

Step

Step 是管道的另一种实现

1
2
3
4
5
6
7
8
9
10
11
<route>
<from uri="activemq:SomeQueue"/>
<step id="foo">
<bean ref="foo"/>
<to uri="activemq:OutputQueue"/>
</step>
<step id="bar">
<bean ref="something"/>
<to uri="log:Something"/>
</step>
</route>

和 PipeLine 的区别,PipeLine 可以理解为 step 的一个逻辑分组,Step 是多个逻辑流程分组的组合,可以在组级别进行异常捕获,可以认为是 PipeLine 的加强版本

参考