I have a scenario in my RabbitMQ setup that I'm curious about how to solve. The diagram below illustrates it (exchanges and most queues removed for succinctness):
Scenario
- Producer creates message A(1), it is received by the top consumer, which begins processing the message.
- Producer creates message A(2), it is received by the bottom consumer (assuming both consumers are on a round-robin exchange).
- The bottom consumer publishes message B(2), which is put into Message B consumer's queue
- The poor slow top consumer finally finishes and emits its message B(1).
Problem
If we assume that B consumer cannot be made idempotent, how do we ensure the result of both B messages are applied in the correct order?
I had thought of using a timestamp that is applied to the initial publish of message A, and having the consumer maintain a timestamp of last change, rejecting any timestamps before that time, but that only works if each message causes the exact same kind of change and requires a lot of tracking.
Other ideas for how to approach this would be appreciated. Thanks!