春季集成汇总的消息两次
我有一个用例,我的消息被分配了两次,我想汇总所有这些消息。如何最好地实现这一目标,我应该通过引入不同的序列标头两次汇总消息,还是有没有办法通过覆盖方法将消息分组的方法分组方式来汇总消息?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我有一个用例,我的消息被分配了两次,我想汇总所有这些消息。如何最好地实现这一目标,我应该通过引入不同的序列标头两次汇总消息,还是有没有办法通过覆盖方法将消息分组的方法分组方式来汇总消息?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
这就是所谓的“嵌套分裂”,并且有内置的算法将序列细节标头推向堆栈以进行新的分裂上下文。这将允许最终具有
上升
聚合:第一个用于最接近嵌套分裂的聚合,弹出序列详细信息标头,并允许下一个聚合器处理其自己的序列上下文。因此,用两个词说:最好在开始时发送一条消息并在最后接收一条消息,那么最好的聚合器是分裂的。
当然,您可以使用
applySequence = false
具有自定义分裂算法。尽可能多。最后只有一个聚合器,但已经具有自定义相关逻辑。我们在文档中有一些解释:
我们没有关于此问题的示例,但这是测试案例的配置: httpps://github.com/spring-proing-proing-proing-project-project-proignt-projects/spring-intement/spring-integratign/春季综合核/src/test/java/org/strprfamework/intempration/gentregator/contregator/scenarios/nestedaggregationTests-context.xml
That's called a "nested splitting" and there is built-in algorithm to push sequence detail headers to the stack for a new splitting context. This would allow in the end to have an
ascendant
aggregation: the first one aggregate for the closest nested splitting, pops sequence detail headers and allows the next aggregator to deal with its own sequence context.So, in two words: it is better to have as many aggregator as you have splitting if you want to send a single message in the start and receive a single message in the end.
Of course you can have a custom splitting algorithm with an
applySequence = false
. As many as you need. And have only a single aggregator in the end, but with a custom correlation logic already.We have some explanation in the docs: https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#aggregatingmessagehandler
We don't have a sample on the matter, but here is a configuration for test case: https://github.com/spring-projects/spring-integration/blob/main/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/NestedAggregationTests-context.xml