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 » Using JMSCorrelationID

Post new topic  Reply to topic
 Using JMSCorrelationID « View previous topic :: View next topic » 
Author Message
APCGR
PostPosted: Mon Jan 21, 2002 10:17 am    Post subject: Reply with quote

Newbie

Joined: 28 Oct 2001
Posts: 7

I'm trying to JMSCorrelationID to correlate requests to responses. The strategy is simple:
1. The request is sent without concern for the JMSCorrelationID but the JMSMessageID is recorded after it is 'set by the Send Method'.
2. The request is received and the JMSMessageID is used to set the JMSCorrelationID of the response.
3.The response is received and the JMSCorrelationID is matched to the JMSMessageID.
Hence: we have the response matched with the original request.

Problem: When the original request is received the JMSMessageID has changed even though I had checked it after the publish???
Secondary Problem: If I respMsg.setJMSCorrelationID(reqMsg.getMessageID()) and
producer.publish(respMsg) when I receive the message the JMSCorrelationID has changed???



Back to top
View user's profile Send private message
APCGR
PostPosted: Mon Jan 21, 2002 7:21 pm    Post subject: Reply with quote

Newbie

Joined: 28 Oct 2001
Posts: 7

I found the problem.... like most things it is very simple once you know.

This is what I was doing:

respMsg.setJMSCorrelationID(reqMsg.getMessageID())

This is what I needed to do:
String correlID = reqMsg.getJMSMessageID();
correlID = correlID.substring(correlID.indexOf(":")+1);
respMsg.setJMSCorrelationID(correlID);

The getJMSMessageID() returns a String with the messageID prefixed with "ID:". I never looked at it... I just used it. The correlationID must be considered invalid at publication time and is therefore overwritten.

It is interesting to note that getCorrelationID() is NOT prefixed with the "ID:". This little incompatibility really bytes.
Back to top
View user's profile Send private message
kolban
PostPosted: Mon Jan 21, 2002 9:55 pm    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

I'm not saying your wrong... if this is what happens then something is badly broken. The Message ID and Correlation ID should be able to be assigned from one to the other without interpretation. I noticed you mentioned publish and not send as the activities. One normally associates request/reply with point-to-point and not pubsub. Can you clarify?
Back to top
View user's profile Send private message
APCGR
PostPosted: Tue Jan 22, 2002 5:48 am    Post subject: Reply with quote

Newbie

Joined: 28 Oct 2001
Posts: 7

Yes I'm using publish and subscribe. This probably seems a little odd that we are using pub/sub and request/reply together but it fits our needs. We have cases where we receive multiple replies to a single request.

I backed out the change to insure that I wasn't dreaming and sure enough the "ID:" came back. To back out the change I did the following (commented line 2):

String correlID = reqMsg.getJMSMessageID();
// correlID = correlID.substring(correlID.indexOf(":")+1);
respMsg.setJMSCorrelationID(correlID);

You can see it if you do a toString() on the TextMessage (i.e. respMsg.toString()):

Here is the primary message: (Notice the JMSMessageID)

JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c22700e00
JMSTimestamp: 1011702263140
JMSCorrelationID:null
JMSDestination: topic://MYAPC.Ping.Request
JMSReplyTo: null
JMSRedelivered: false
JMSXAppID:MQSeries Client for Java
JMSXUserID:MUSR_MQADMIN
JMSXDeliveryCount:0
JMS_IBM_PutApplType:28
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Ping SYSTEM "./ping.dtd" >
<Ping messageSequenc
Another 280 character(s) omitted

Here is the response message: (Notice that the JMSCorrelationID has the extra "ID:" now.)

JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d512067726567672e71756575652e06014c3cf2d20d00
JMSTimestamp: 1011702263150
JMSCorrelationID:ID:414d512067726567672e71756575652e06014c3c12600e00
JMSDestination: topic://MYAPC.Ping.Request
JMSReplyTo: null
JMSRedelivered: false
JMS_IBM_MsgType:8
JMSXAppID:gregg.queue.manager
JMSXUserID:MUSR_MQADMIN
JMSXDeliveryCount:1
JMS_IBM_PutApplType:26
JMS_IBM_Format:MQSTR

[ This Message was edited by: APCGR on 2002-01-22 05:53 ]
Back to top
View user's profile Send private message
kolban
PostPosted: Tue Jan 22, 2002 8:31 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Still not with you, I see the following:

JMSCorrelationID:ID:414d512067726567672e71756575652e06014c3c12600e00

This seems to show that property
"JMSCorrelationID" has the value "ID:414d512067726567672e71756575652e06014c3c12600e00".

Nothing odd with that? In JMS, all message ids and correlation ids are strings and start with the code "ID:"
Back to top
View user's profile Send private message
APCGR
PostPosted: Tue Jan 22, 2002 2:36 pm    Post subject: Reply with quote

Newbie

Joined: 28 Oct 2001
Posts: 7

Sorry for the confusion.

The example that I showed you in my previous posting is without my fix. When that message is actually published the underlying mqjms implementation will throw-up on the "ID:" string in the correlationID and will overwrite correlationID with some unexpected value.

I understand that you are saying messageID and correlationID should be comaptible but they are not. If you don't strip the "ID:" off the front of the messageID the underlying mqjms implementation will overwrite the correlationID.

Here is a bad sceanrio followed by a good scenario. I trimmed out all the extraneous stuff. I am also using a very simple correlationID. In the bad scenario I use "ID:1111" and the good scenanrio "1111".

Bad Scenario:
Request message published:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c22a01900
JMSTimestamp: 1011734599150
JMSCorrelationID:null

Request message received:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c62f81800
JMSTimestamp: 1011734599160
JMSCorrelationID:ID:414d512067726567672e71756575652e06014c3c12901900

Response message published:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c22e01900
JMSTimestamp: 1011734599480
JMSCorrelationID:ID:1111 <<<< notice the "ID:"

Response message received:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c42fa1800
JMSTimestamp: 1011734599480
JMSCorrelationID:ID:414d512067726567672e71756575652e06014c3c22b01900 <<< created by mqjms
End of Bad scenario:

Good scenario:
Request message published:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c22101a00
JMSTimestamp: 1011735158970
JMSCorrelationID:null

Request message received:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3cc2fa1800
JMSTimestamp: 1011735158980
JMSCorrelationID:ID:414d512067726567672e71756575652e06014c3c12001a00

Response message published:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3c22501a00
JMSTimestamp: 1011735159400
JMSCorrelationID:1111

Response message received:
JMSMessageID: ID:414d512067726567672e71756575652e06014c3ca2fc1800
JMSTimestamp: 1011735159400
JMSCorrelationID:1111
End of Good scenario:



[ This Message was edited by: APCGR on 2002-01-22 15:00 ]
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 » Using JMSCorrelationID
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.