|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Auto generation of CorrelationID in JMS? |
« View previous topic :: View next topic » |
Author |
Message
|
jase_t_thomas |
Posted: Mon Feb 08, 2010 2:39 am Post subject: Auto generation of CorrelationID in JMS? |
|
|
Newbie
Joined: 08 Feb 2010 Posts: 6
|
Hi,
Does anyone know if the correlation ID can be auto-generated using the JMS/MQ interface?
I am aware that using the MQ Java API, it is possible to set the MQC.MQPMO_NEW_CORREL_ID on the MQPutMessageOptions object.
However, I can't see a way to do this automatically in the JMS API interface (with MQ) ?
At the moment, I am randomizing a byte[24] array and setting this manually by using the setJMSCorrelationId() function. I'd prefer to allow MQ to do this if possible.
Anyone know if it is feasible?
Rgds,
J |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 09, 2010 9:13 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Remember that in JMS the send method automatically generates a new message id. Best practice says:
If the request correlationId is initial (hex 000...) send the reply with the messageid of the request as correlation id.
If the correlationId is set on the request message it is a passthrough to the reply.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rajess_kr |
Posted: Mon Mar 01, 2010 11:01 am Post subject: Auto generation of CorrelationID in JMS? |
|
|
Newbie
Joined: 26 Feb 2010 Posts: 8
|
did u get get it to work? |
|
Back to top |
|
 |
jase_t_thomas |
Posted: Tue Mar 02, 2010 1:10 am Post subject: |
|
|
Newbie
Joined: 08 Feb 2010 Posts: 6
|
No. I found nothing to indicate that it was possible using the JMS/MQ standard.
The comment above from fjb_saper does not answer my question, but merely asks why we are not following a different standard. Of course, it is quite acceptable to use a different standard which is for a request/response to match using the correlation id on both legs of the message.
In the end, I used the Java.Random.nextBytes(), passing in a 24 byte array, along with the setJMSCorrelationId to do this outside of MQ/JMS. Performance profiling indicates this shouldnt be a problem. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 02, 2010 8:30 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jase_t_thomas wrote: |
No. I found nothing to indicate that it was possible using the JMS/MQ standard.
The comment above from fjb_saper does not answer my question, but merely asks why we are not following a different standard. Of course, it is quite acceptable to use a different standard which is for a request/response to match using the correlation id on both legs of the message.
In the end, I used the Java.Random.nextBytes(), passing in a 24 byte array, along with the setJMSCorrelationId to do this outside of MQ/JMS. Performance profiling indicates this shouldnt be a problem. |
And if you wanted to ensure uniqueness of the correlation Id I would have suggested that you write a message with short expiry to a queue and use the messageId of that message to populate the correlation id of your request. The queue being written to should be read from at interval x to make sure the expired messages get removed...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|