我有一条路线,我希望 Camel 访问以下 beans:
- 首先,
loggingBean
- 第二,一个
aggregator
等待一定数量的消息在其上聚合 - 一旦聚合器的
completionSize
到达(3),继续#4 - 第三,
processorBean
- 第四个/最后一个,
finalizerBean
这是我的路线:
<route id="my-camel-route">
<from uri="direct:starter" />
<to uri="bean:loggingBean?method=shutdown" />
<aggregate strategyRef="myAggregationStrategy" completionSize="3">
<correlationExpression>
<simple>${header.id} == 1</simple>
</correlationExpression>
<to uri="bean:processorBean?method=process" />
</aggregate>
<to uri="bean:finalizerBean?method=shutdown" />
</route>
我的问题:我需要放置 finalizerBean
内部<aggregate>
像这样的元素:
<aggregate strategyRef="myAggregationStrategy" completionSize="3">
<correlationExpression>
<simple>${header.id} == 1</simple>
</correlationExpression>
<to uri="bean:processorBean?method=process" />
<to uri="bean:finalizerBean?method=shutdown" />
</aggregate>
基本上,我想知道我当前的处理方式是否会提示 Camel 将消息发送到聚合器,然后也将其发送到 finalizerBean
(本质上,绕过聚合器)。就我而言,我希望它聚合直到 completionSize
是 3,然后将聚合的交换发送到 processorBean
最后finalizerBean
.
或者我是否正确配置了这个? finalizerBean
和有什么不一样?在 <aggregate>
内元素与外部?
最佳答案
第二个例子是正确的。
<aggregate strategyRef="myAggregationStrategy" completionSize="3">
<correlationExpression>
<simple>${header.id} == 1</simple>
</correlationExpression>
<to uri="bean:processorBean?method=process" />
<to uri="bean:finalizerBean?method=shutdown" />
</aggregate>
如果 FinalizerBean 位于 <aggregate>
“外部” ,它将针对来自 direct:starter
的每条消息执行。 - 这不是你想要的;)
关于java - 正确使用Camel Aggregator "to"URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21457909/