ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem with getJMSCorrelationID

Post new topic  Reply to topic
 Problem with getJMSCorrelationID « View previous topic :: View next topic » 
Author Message
qojote
PostPosted: Fri Jun 24, 2005 1:58 am    Post subject: Problem with getJMSCorrelationID Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Fri Jun 24, 2005 3:23 am    Post subject: Reply with quote

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
View user's profile Send private message
qojote
PostPosted: Fri Jun 24, 2005 4:53 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Fri Jun 24, 2005 4:58 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 24, 2005 12:03 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
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
View user's profile Send private message Send e-mail
qojote
PostPosted: Sun Jun 26, 2005 11:02 pm    Post subject: Reply with quote

Newbie

Joined: 24 Jun 2005
Posts: 3

Thanks.

Now I got it
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem with getJMSCorrelationID
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.