问题
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