activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Get message ID from producer.send(message)
Date Thu, 15 Jun 2006 12:15:57 GMT
On 6/15/06, ENP <prokopiev@stc.donpac.ru> 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.
http://incubator.apache.org/activemq/how-should-i-implement-request-response-with-jms.html

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...

http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/util/IdGenerator.html

Unless you're on Java 5 in which case you can use...
http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html
-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message