0
votes

JMS Queue is having 2 consumers, synchronous and asynchronous Java application process waiting for the response. 1)Synchronous application send request and will be waiting for the response for 60 seconds based on the JMS correlation ID. 2)Asynchronous thread will be constantly listening on the same queue.

In this scenario, when the response is received on the queue within 60 second I would expect load is distributed on both synchronous and asynchronous application. However, for some unknown reason almost all the response messages are consumed by synchronous process. And,only in some cases the messages are picked up asynchronous process.

Are there any factors that could cause only synchronous application to pick almost all the messages?

1

1 Answers

0
votes

There is usually no guarantee that the load will be distributed evenly, especially if its synchronous versus async. consumer. The synchronous consumer will have to poll, wait, poll, wait while the async. consumer is probably waiting on the socket in a separate thread until a message arrives and then call your callback. So the async. consumer will most always be there first.

Any chance you can change to Topics and discard messages you don't wont ? Or change your sync. consumer to be async ? Another alternative would be to build a small 'asnyc' gateway in front of your synchronous consumer: a little application that makes an async consumption and then copies each message received to a second queue where the sync. consumer picks it up. Depending on your JMS provider it might support this type of 'JMS bridge' already - what are you using ?