Author |
Message
|
qojote |
Posted: Fri Jun 24, 2005 1:58 am Post subject: Problem with getJMSCorrelationID |
|
|
Newbie
Joined: 24 Jun 2005 Posts: 3
|
Hi,
i 've created an new message an set it's correlationID to an value for example abcd12345.
but when i try to get this correlation ID with my receiver i get something like this 3142535243643264634634.
With the message id i have the same problem.
When i have a look to the message with a tool called Mq explorer.
It show's me both values the one that i 've set and the one i get when i try to get the correlation id by get.JmsCorrelationID().
Where's the mistake i'm making.
Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 24, 2005 3:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why are you trying to set the correlation ID? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
qojote |
Posted: Fri Jun 24, 2005 4:53 am Post subject: |
|
|
Newbie
Joined: 24 Jun 2005 Posts: 3
|
Because it's an reply to an message.
and i want to set it to the message id of the request message. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 24, 2005 4:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
From the IBM sample code at http://www.developer.ibm.com/isv/tech/sampmq.html
MQJMSSRV.java
Code: |
/**************************************************/
/* Get the message id from the request message. */
/* It will be used as the reply's correlation id. */
/**************************************************/
String msgID = msg.getJMSMessageID();
/***************************************************/
/* Need to get the destination that the reply will */
/* go to. This destination then needs to be used */
/* to create a QueueSender to send the actual */
/* reply. Just for curiosity, print out the name */
/* of the destination. */
/***************************************************/
Destination des = msg.getJMSReplyTo();
String desQueueName = ((Queue)des).getQueueName();
System.out.println(" server replyToQ: " + desQueueName);
Queue desQueue = session.createQueue(desQueueName);
QueueSender qSender = session.createSender(desQueue);
TextMessage msg1 = session.createTextMessage();
msg1.setText(replyString);
msg1.setJMSCorrelationID(msgID); /* set correlation id of */
/* reply to request's */
/* message id */
qSender.send(msg1); |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jun 24, 2005 12:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20763 Location: LI,NY
|
And even there they do stuff that is way too complex
The easy way would be:
Code: |
Destination des = msg.getJMSReplyTo();
String desQueueName = ((Queue)des).getQueueName();
System.out.println(" server replyToQ: " + desQueueName);
QueueSender qSender = session.createSender(des);
TextMessage msg1 = session.createTextMessage();
msg1.setText(replyString);
msg1.setJMSCorrelationID(msgID); /* set correlation id of */
/* reply to request's */
/* message id */
qSender.send(msg1); |
Notice no longer any monkeying around with the reply to queue. It is taken and just plugged into the reply message. The rest is just display (window dressing)... If need be you might have to cast the Destination to a Queue....
Enjoy  |
|
Back to top |
|
 |
qojote |
Posted: Sun Jun 26, 2005 11:02 pm Post subject: |
|
|
Newbie
Joined: 24 Jun 2005 Posts: 3
|
|
Back to top |
|
 |
|