Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

java - JMS Dynamic Message Selection

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.7k users

...