问题
I would like to know if I can have persistence in my Spring Integration setup when I use a aggregator, which is not backed by a MessageStore, by leveraging the persistence of AMQP (RabbitMQ) queues before and after the aggregator. I imagine that this would use ack's: The aggregator won't ack a message before it's collected all the parts and sent out the resulting message. Additionally I would like to know if this is ever a good idea :)
I am new working with queue's, and am trying to get a good feel for patterns to use.
My business logic for this is as follows:
- I receive a messages on one queue.
- Each message must result in two unrelated webservice calls (preferably in parallel).
- The results of these two calls must be combined with details from the original message.
- The combination must then be sent out as a new message on a queue.
Messages are important, so they must not be lost.
I was/am hoping to use only one 'persistent' system, namely RabbitMQ, and not having to add a database as well.
I've tried to keep the question specific, but any other suggestions on how to approach this are greatly appreciated :)
回答1:
What you would like to do recalls me Scatter-Gather EI Pattern.
So, you get a message from the AMQP send it into the ScatterGather
endpoint and wait for the aggregated reply. That's enough for to stick with the default acknowledge.
Right, the scatterChannel
can be PublishSubscribeChannel
with an executor to call Web Services in parallel. Anyway the gatherer process will wait for replies according the release strategy and will block the original AMQP listener do not ack the message prematurely.
来源:https://stackoverflow.com/questions/47416186/message-persistence-in-spring-integration-aggregator-without-messagestore-by-usi