I have a message queue containing a customer id and some of their data. To improve performance those messages will be processed by multiple threads. My issue is that I need to find a way to ensure the message order for individual customers.
To give an example, take a financial system with a queue of transactions:
- Message1: customer: 1, deposit: 10, withdrawal: 0
- Message2: customer: 2, deposit: 10, withdrawal: 0
- Message3: customer: 1, deposit: 0, withdrawal: 5
- Message4: customer: 1, deposit: 0, withdrawal: 5
Messages 1 and 2 could be processed in parallel but Message 3 shouldn't be processed until Message 1 is complete and Message 4 shouldn't be processed until Message 3 has completed.
I feel the ideal situation would be for the message to only be dequeued once it is processable? Does anyone know if that is possible? It may be worth noting I'm currently using RabbitMQ but this is flexible.
question from:
https://stackoverflow.com/questions/65683060/jms-dynamic-message-selection 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…