What’s the best way to implement a Request/Reply pattern if no temporary queues are available?

The customary solution when several requestors listen for replies on the same queue is to use correlation IDs to select messages. On the client side it looks like this:

Place a message on the request queue and commit.
Retrieve the JMSMessageID from the outbound message (the value is determined by the broker and updates the message object as a result of the send).
Receive a message from the reply queue specifying the JMSMessageID from the outbound message as the correlation ID in the selector.
Process and commit.
On the server side it looks like this:

Receive a message under syncpoint.
Process the request and prepare the response.
Set the JMSCorrelationID on the response to the value of JMSMessageID from the request.
Send the message.
Commit.
The consumer would set the selector something like this: activemq.selector:JMSCorrelationID=.

Since the broker creates a message ID that is supposed to be globally unique, the pattern of using it as the correlation ID prevents collisions that are possible when each requestor is allowed to specify it’s own value.

http://stackoverflow.com/questions/4849964/whats-the-best-way-to-implement-a-request-reply-pattern-if-no-temporary-queues#