apache-camel - Apache Camel - 创建聚合器 'flush'

标签 apache-camel aggregation

我实际上想要刷新或完成大小,但对于聚合器中的所有聚合。就像全局的completionSize一样。

基本上,我想确保批量传入的每条消息都被聚合,然后在读取最后一条消息时立即完成该聚合器中的所有聚合。

e.g. 1000 messages arrive (the length is not known beforehand)

     aggregate on correlation id into bins
        A 300
        B 400
        C 300   (size of the bins is not known before hand)

     I want the aggregator not to complete until the 1000th exchange is aggregated
     thereupon I want all of the aggregations in the aggregator to complete at once

CompleteSize 适用于每个聚合,不幸的是,不适用于整个聚合器。因此,如果我设置 CompleteSize( 1000 ),它将永远不会完成,因为每个聚合必须超过 1000 才能“完成”

我可以通过构建单个 Map 对象来解决这个问题,但这有点回避 aggregator2 中的相关性,我更愿意理想地使用它

所以是的,无论是全局完整大小还是刷新,有没有办法智能地做到这一点?

最佳答案

一种选择是简单地添加一些逻辑来保留全局计数器,并在达到时设置 Exchange.AGGREGATION_COMPLETE_ALL_GROUPS header ...

Available as of Camel 2.9...You can manually complete all current aggregated exchanges by sending in a message containing the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true. The message is considered a signal message only, the message headers/contents will not be processed otherwise.

关于apache-camel - Apache Camel - 创建聚合器 'flush',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15070864/

相关文章:

apache-camel - Apache Camel/ActiveMQ 优先路由

java - 使用 Pidgin 测试 XMPP Camel 路由

java - Camel创建具有特定名称的文件

elasticsearch - 如何使用 Elasticsearch 过滤最后 5 分钟的日期直方图?

node.js - 客户应该为每个集合或每个文档制作一个变更流吗?

r - 打破tapply瘾君子的习惯

elasticsearch - Elasticsearch聚合。按嵌套存储桶doc_count排序

java - Camel http 组件不关闭连接 - Close_Wait

java - 将camel-spring-boot从2.18升级到2.19时使用FatJarRouter

node.js - Elasticsearch 对部分字符串而非完整字符串进行聚合