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().
/**************************************************/
/* 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.
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
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