JMS Dynamic Message Selection

Tags: , , ,



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.

Answer

The message grouping feature of ActiveMQ Artemis sounds like it would be a good fit for this use-case.

From what I understand RabbitMQ doesn’t support this kind of functionality.



Source: stackoverflow