On 6/15/06, ENP <[EMAIL PROTECTED]> 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/
