How to concurrently process the asynchronous jms queue message?

≡放荡痞女 提交于 2019-12-25 12:19:12

问题


My JMS consumer produces any number of messages on a JMS queue during the day. As soon as a message arrives it goes to message listener. If in between I need some other message comes, it goes to another message listener does not wait for first one?

As per my understanding here I need to create two consumer(assume i want to process 2 message concurrently) each having its own session. Both consumer can use the same message listener. Right?

I am not sure if I can achieve it with single consumer but can I with multiple listeners?

something like this Single queue: concurrent message processing with multiple consumers


回答1:


Per the JMS documentation @bgth cites, multiple MessageListeners in a single session will not provide concurrency:

"The session used to create the message consumer serializes the execution of all message listeners registered with the session. At any time, only one of the session’s message listeners is running"

For concurrency, you need multiple sessions and multiple consumers in separate threads. You can reuse the same MessageListener in this case, but it must be threadsafe.



来源:https://stackoverflow.com/questions/22890086/how-to-concurrently-process-the-asynchronous-jms-queue-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!