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 » 2033 when MQMO_MATCH_CORREL_ID used - JMS/MQ mix

Post new topic  Reply to topic
 2033 when MQMO_MATCH_CORREL_ID used - JMS/MQ mix « View previous topic :: View next topic » 
Author Message
HMed
PostPosted: Sat Sep 18, 2004 8:03 am    Post subject: 2033 when MQMO_MATCH_CORREL_ID used - JMS/MQ mix Reply with quote

Novice

Joined: 17 Sep 2004
Posts: 17
Location: Camp Hill, PA. - USA

I have a situation where program1 puts a message on an MQ queue using default msgid and correlationids. I then move the msgid to the correlation id and "000000000000000000000001".getBytes() to the msgid for future matching of the reply.

Program2, a MDB picks up the msgid in JMS format (ascii hex), converts the msgid to integer, using parseint radix, byteshift, bytearray ect. and moves it to the correlationId. It then moves "000000000000000000000001".getBytes() to the msgid and uses MQ classes to send the msg to the reply queue. (ps, I am aware of the prefix JMS puts on the msgid, and that has been taken into account)

At this point, program1 gets the reply message, but is not able to match when using correlationid in the GMO's. It is able to match when not using correlationID in the GMO's. I can display (in ascii hex) the sending msgid after the put (above) and the receiving correlation id after the get, and they are identical.

Here is the code of the put and the get. Does anybody know if I should be using an additional parameter to ensure matching, if I should remove Quiescing, transport or other properties? Any help is truly appreciated.




private final static int MQ_Reply_Queue_Open_Options =
MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING;

private byte[] correlationId = { 1 };

private byte[] messageId;

mqenv = new MQEnvironment();
mqenv.hostname = hostName;
mqenv.channel = channel;
mqenv.port = port;
mqenv.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);

queueMgr = new MQQueueManager(reqQMgrName);

reqQueue =
queueMgr.accessQueue(
reqQueueName,
MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING,
null,
null,
null);

MQMessage mqmsg = new MQMessage();

mqmsg.replyToQueueManagerName = repQMgrName;
mqmsg.replyToQueueName = repQueueName;

mqmsg.messageType = MQC.MQMT_REQUEST;
mqmsg.format = MQC.MQFMT_STRING;

mqmsg.writeBytes(msg);

MQPutMessageOptions pmo = new MQPutMessageOptions();

pmo.options = MQC.MQPMO_FAIL_IF_QUIESCING;

reqQueue.put(mqmsg, pmo);

correlationId = mqmsg.messageId;

//****************************************************
//**** this code used to verify and display correlationid / msgid
//**** in hex format
//****************************************************

String tmp2 = new String(correlationId);

byte ch = 0x00;
int iz = 0;
String pseudo[] = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" };
StringBuffer out1 = new StringBuffer(correlationId.length * 2);

while (iz < correlationId.length) {
ch = (byte) (correlationId[iz] & 0xF0); // Strip off high nibble
ch = (byte) (ch >>> 4); // shift the bits down
ch = (byte) (ch & 0x0F); // must do this is high order bit is on!
out1.append(pseudo[(int) ch]); // convert the nibble to a String Character
ch = (byte) (correlationId[iz] & 0x0F); // Strip off low nibble
out1.append(pseudo[(int) ch]); // convert the nibble to a String Character
iz++;
}
String rslt = new String(out1);

eeobLog.debug("Sent messageId = " + rslt + " returning correlation id should match" );

//****************************************************
//**** this code used to verify and display correlationid / msgid
//**** in hex format
//****************************************************

reqQueue.close();

/**
* This method gets the reply back from mq
*/


byte[] pdfBytes = { 1 };

MQQueueManager repQueMgr = null;

mqenv.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);

repQueMgr = new MQQueueManager(repQMgrName);

repQueue =
repQueMgr.accessQueue(
repQueueName,
MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_BROWSE | MQC.MQOO_INQUIRE,
null,
null,
null);

MQMessage replyMessage = new MQMessage();

MQGetMessageOptions getMsgOptions = new MQGetMessageOptions();

replyMessage.correlationId = correlationId;

replyMessage.messageId = "000000000000000000000001".getBytes();

getMsgOptions.options= MQC.MQMO_MATCH_MSG_ID |
MQC.MQMO_MATCH_CORREL_ID | MQC.MQGMO_WAIT | MQC.MQSEG_ALLOWED;

getMsgOptions.waitInterval=30000;

repQueue.get(replyMessage, getMsgOptions,repQueue.getMaximumMessageLength());


//****************************************************
//**** this code used to verify and display correlationid / msgid
//**** in hex format
//****************************************************

byte ch = 0x00;
int iz = 0;
String pseudo[] = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" };
StringBuffer out1 = new StringBuffer( replyMessage.correlationId.length * 2);

while (iz < replyMessage.correlationId.length) {
ch = (byte) ( replyMessage.correlationId[iz] & 0xF0); // Strip off high nibble
ch = (byte) (ch >>> 4); // shift the bits down
ch = (byte) (ch & 0x0F); // must do this is high order bit is on!
out1.append(pseudo[(int) ch]); // convert the nibble to a String Character
ch = (byte) ( replyMessage.correlationId[iz] & 0x0F); // Strip off low nibble
out1.append(pseudo[(int) ch]); // convert the nibble to a String Character
iz++;
}
String rslt = new String(out1);

eeobLog.debug("Recieved correlationId = " + rslt );

//****************************************************
//**** this code used to verify and display correlationid / msgid
//**** in hex format
//****************************************************

//****************************************************
//**** at this point I get the 2033, but if I take out the
//**** MQC.MQMO_MATCH_CORREL_ID I can successfully get msg
//****************************************************

//
replyMessage.readFully(pdfBytes);
repQueue.close();

repQueMgr.disconnect();
repQueMgr.close();
Code:
Code:
Back to top
View user's profile Send private message Send e-mail
RogerLacroix
PostPosted: Sat Sep 18, 2004 9:07 am    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Hi,

The first thing is to have both programs STOP trying to set the MsgId field. This will only cause great headaches.

The requesting program should only use defaults for MsgID & CorrelID:
Code:
sendMsg.messageId = MQC.MQMI_NONE;
sendMsg.correlationId = MQC.MQCI_NONE;
// Plus other important fields
sendMsg.replyToQueueManagerName = repQMgrName;
sendMsg.replyToQueueName = repQueueName;
sendMsg.messageType = MQC.MQMT_REQUEST;
sendMsg.format = MQC.MQFMT_STRING;
// do the put now....

// and after the put save the returned CorrelID
savedCorrelID = sendMsg.correlationId;

The buiness component processing the request messages should just get the next available message from the 'request' queue and then save 3 fields (MsgID, ReplyToQ & ReplyQMgr):
Code:
MQMessage getMsg = new MQMessage();
getMsg.messageId = MQC.MQMI_NONE;
getMsg.correlationId = MQC.MQCI_NONE;
// now get the message

// Save important fields
replyCorrelID = getMsg.messageId;
replyReplyToQ = getMsg.replyToQueueName;
replyReplyToQMgr = getMsg.replyToQueueManagerName;
// Now do business logic

// Open the output with replyReplyToQMgr & replyReplyToQ

// Next build reply message
MQMessage replyMsg = new MQMessage();
replyMsg.messageId = MQC.MQMI_NONE;
replyMsg.correlationId = replyCorrelID;
// Plus other important fields
replyMsg.messageType = MQC.MQMT_REPLY;
replyMsg.format = MQC.MQFMT_STRING;


Finally, the requesting program will do get as follows:
Code:
MQMessage inMsg = new MQMessage();
inMsg.messageId = MQC.MQMI_NONE;
inMsg.correlationId = savedCorrelID; 
// Options
MQGetMessageOptions getMsgOptions = new MQGetMessageOptions();
getMsgOptions.options = MQC.MQGMO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT;
getMsgOptions.matchOptions = MQC.MQMO_MATCH_CORREL_ID;
getMsgOptions.waitInterval = 30000;
// Get the matching reply message

Hopefully, that will clear things up.

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Sat Sep 18, 2004 12:55 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Quote:
Program2, a MDB picks up the msgid in JMS format (ascii hex), converts the msgid to integer, using parseint radix, byteshift, bytearray ect. and moves it to the correlationId.


That sounds awfully complicated to me. Would it not be easier to have:
(from memory)
Code:
replyMsg.setJMSCorrelationID(requestMsg.getJMSMessageID());
??

Why bother in interpretation of something that should not be touched?

As well on the sending side let the qmgr handle the messageId. Do not set it yourself. Easier this way.
Enjoy
F.J.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » 2033 when MQMO_MATCH_CORREL_ID used - JMS/MQ mix
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.