Search code examples
javaspringjmsmessage-driven-bean

Concurrent Processing - JMS


I saw one of the applications in my company make concurrent calls using JMS. The app is a webservice written in Spring. This makes a number of external calls. When a request is received for an operation , it posts a number of messages to JMS queues and a MDB processes the messages. The application then collates all the responses , maps it back to its data model and returns the response. I have in the past used JMS to make fire and forget calls , but i am not able to figure out how the app is waiting for the response from JMS queue. Please can you explain if there is a way to do it?


Solution

  • Vicky , one way that this is done is using a business correlation. Messaging in a true sense is asynchronous. But is possible to use "psuedo-synchronous" call. The way to do that is to use a ID when posting the request and on the same thread , poll the response with a JMSMessageSelector (with the same ID). Additionally , you can also do aggregation if there are multiple backends , this is also possible by having a part id in the message and having a poll to see if all the "parts are assembled" , before aggregating and sending a response. The JMS Message Selector. A high level overview of the patterns are documented here as well