我实际上想要刷新或完成大小,但对于聚合器中的所有聚合。就像全局的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/