onejigtwojig
onejigtwojig

Reputation: 4851

Creating a JMS Correlation ID

It is generally discouraged to use the message id returned from the JMS provider as the correlation id with which a message is published onto a queue. How have people generated their correlation ids for a request/response architecture?

Upvotes: 13

Views: 28858

Answers (2)

Maverick
Maverick

Reputation: 648

Server-side correlation ID generation suffers from two problems though:

  1. One-way protocols (like JMS) have no direct means of returning the correlation ID back to the client. Another channel could be used but that complicates things.

  2. Unexpected issues can prevent the client from receiving the generated ID even though the request has been accepted and processed on the server. This is why client ID generation should be considered.

Client generated correlation IDs

Clients can use a unique ID standard like UUID to generate a new ID

  message.setJMSCorrelationID(UUID.randomUUID().toString());

Ref: http://blogs.mulesoft.com/dev/anypoint-platform-dev/total-traceability/

Upvotes: 2

Sandip Armal Patil
Sandip Armal Patil

Reputation: 5905

Clients can use a unique ID standard like UUID to generate a new ID. Here is good tutorial for you.

You can return correlation id from JMS provider using following code.

message.setJMSCorrelationID(UUID.randomUUID().toString());
producer.send(message);
LOG.info("jms-client sent:" + message.getJMSCorrelationID());  

Cheers.

Upvotes: 2

Related Questions