Tuesday, March 4, 2014

JMS ReplyTo - How does it work?

Scenario 1
In this scenario the Destination is pre-configured and hence proven to work. There is not much value to set this destination as a value for JMSReplyTo header as the receiver might already know about the existence of this pre-configured destination.
Scenario 2
In this scenario the sender creates a temporary Destination and receiver will know about this only by calling getJMSReplyTo() method on the received Message. This kind of establishes a private channel between sender and receiver. Read this nice article on pros and cons of temporary destinations.
Sample code
Queue tempQueue = qSession.createTemporaryQueue();
TextMessage request = qSession.createTextMessage();
request.setJMSReplyTo(tempQueue);
QueueReceiver qReceiver = qSession.createReceiver(tmpQueue);
Message response = qReceiver.receive();
http://stackoverflow.com/questions/8846330/jms-replyto-how-does-it-work

No comments:

Post a Comment