Friday, 30 August 2013

Synchronous Request-Reply pattern in a J2EE container

Synchronous Request-Reply pattern in a J2EE container

I am looking to implement an synchronous Request-Reply pattern using JMS
inside a J2EE container. The sequence would be something like this
Browser makes a request to web application for data. This is a blocking
request (say on thread T1).
The Web app needs to connect to a remote web service to fulfill the above
request. So it forms a request and places it on a queue (with a reply-to
queue also declared).
The remote service processes the requests and places the response on to
the reply-to queue declared in step 2
The response is read from the reply-to Q in the web-app and made available
to the blocking thread T1 of step 1.
I have followed the answer provided by T.Rob (How to match MQ Server reply
messages to the correct request)
QueueReceiver queueReceiver =
session.createReceiver(destination, "JMSCorrelationID='customMessageId'");
TextMessage receivedMessage = (TextMessage)queueReceiver.receive( 15000 );
Is the above solution valid when running in a J2EE container (web module)
where there could be multiple concurrent request coming in?

No comments:

Post a Comment