activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Get message ID from producer.send(message)
Date Thu, 15 Jun 2006 12:15:57 GMT
On 6/15/06, ENP <> wrote:
> Hi,
> Is it possible to get AMQ-generated message ID after executing
> producer.send(message) in any way?

Yes - just access the Message.getJMSMessageID() after you've called send().

> It can be very useful to associate request with replay. Any other technique
> require generating unique number (GUID?) and use it as custom message header
> or name of temp topic :(

To correlate requests to responses you should use the JMSCorrelationID header.

this allows you to attach the correlation ID to the message before its
sent; then services which process your message and reply with results
should attach the correlation ID from the request to any responses.

BTW if you are using a JMSReplyTo header for responses which the
client side uses a temporary queue, the correlation ID can just be an
incrementing long as a String. There's no need for it to be a full
GUID as the temporary queue acts as a GUID.

But if you really want a GUID then use this utility class...

Unless you're on Java 5 in which case you can use...


View raw message