Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 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.

question from:https://stackoverflow.com/questions/65683060/jms-dynamic-message-selection

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

1 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...