java - 正确使用Camel Aggregator "to"URI

标签 java apache-camel aggregation

我有一条路线,我希望 Camel 访问以下 beans:

  1. 首先,loggingBean
  2. 第二,一个 aggregator等待一定数量的消息在其上聚合
  3. 一旦聚合器的 completionSize到达(3),继续#4
  4. 第三,processorBean
  5. 第四个/最后一个,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/

相关文章:

java - 插入 xml :space ='preserve' in the DOM

java - 从 PHP 执行 java MySQL 存储过程

java - 已实现的链表中的 Get 方法,Java

ssl - 带 Camel 的 CXF - HTTPS

java - 如何在 Camel HTTP 代理中获取和设置参数

java - 无法在 Camel 端点中设置 ActiveMQ 目标选项

javascript - 如何获取 mongodb 聚合上所有条目的对象数组的值重复计数

java - 通过 TCP/IP 接收对象

python - 如何在 python/pandas 中解压缩/解聚合分层数据?

elasticsearch - 聚合低于值的最大时间戳