0

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?

Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
  • Totally a guess, but it sounds like there needs to be some way to say "I'm done". You can still use fire and forget but both sides need to know when the stream of messages is complete. The "poison pill" / EOF type of design is common in async architectures that are really not totally async. – stdunbar Sep 07 '16 at 22:56

1 Answers1

1

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

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24