Print
Request Response with JMS

There is some background on how to implement request-response efficiently with JMS.

Lingo provides a simple Requestor abstraction for working with JMS to provide one way and request response message exchanges. e.g.

// dependency injected values
Requestor requestor = ...; 
Destination destination = ...;

// now lets do a one way
String text = "Hello World";
Message message = requestor.getSession().createTextMessage(text);
requestor.send(destination, message);

// now lets do a blocking request response
Message request = requestor.getSession().createTextMessage("How are you?");
Message response = requestor.request(destination, request);

The most efficient implementation is the MultiplexingRequestor which uses a single temporary queue and connection & session for multiple threads, then uses a JMSCorrelationID on each message so that requests and responses can be matched together.

Powered by Atlassian Confluence