How to aggregate RabbitMq messages into single message by correlation ID

寵の児 提交于 2020-01-13 04:42:08

问题


Let's say that I have a pipeline of commands that need to be executed sequentially and that some of the commands contain multiple operations that should be executed in parallel (same correlation id). And let's assume that I need to know when all parallel operations are executed in order to proceed with execution further in the pipeline.

Is it possible to achieve this kind of orchestration with RabbitMQ alone by using exchanges and queues without usage of external data sources like database ?

I am interested in the following use case: I have just published 3 messages of the same type on the same queue. Those messages are being processed in parallel. I would like to publish a new message only when all messages of the same correlation ID are finished successfully.

Is there a way to achieve this with RabbitMQ ?


回答1:


It sounds like you could use the scatter-gather pattern. This explains that pattern quite well with a diagram:

http://www.enterpriseintegrationpatterns.com/patterns/messaging/BroadcastAggregate.html

And here is a tutorial on how to implement with RabbitMQ: http://geekswithblogs.net/michaelstephenson/archive/2012/08/06/150373.aspx



来源:https://stackoverflow.com/questions/39267475/how-to-aggregate-rabbitmq-messages-into-single-message-by-correlation-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!