Author |
Message
|
wfudeac92 |
Posted: Wed May 10, 2006 10:17 am Post subject: Question about the MQMD MessageID Property |
|
|
Novice
Joined: 24 Apr 2006 Posts: 21
|
I am looking through some MQ code that I inherited and I have a question about the MessageID property on the MQMD. For some reason, the application generates its own 24 character Message ID and sets the MessageID property on the MQMD to that value before doing the MQPUT. After the MQPUT, we take the MessageID from the MQMD and use that message id to do a get. I have looked through a lot of sample code from IBM and they never generate a MessageID, they just use the Message ID that is returned from the MQPUT to do the MQGET.
Why do you want to generate your own MessageId's? If you do generate your own MessageID, does MQ generate another MessageID after the MQPUT or does it just pass you back the MessageID that you generated? Does it matter whether or not you are using a Datagram when doing the MQPUT? Here is a snippet of the code that I am talking about.
// MQPUT
mqMessage.MessageId = AsciiToEbcdicArray(messageID);
mqQueue.Put(mqMessage, mqPMO);
messageIDPut = mqMessage.MessageId;
.........
// MQGET
MQGetMessageOptions mqGMO = new MQGetMessageOptions();
MQMessage mqMessageReply = new MQMessage();
mqMessageReply.MessageId = messageIDPut;
mqGMO.MatchOptions = MQC.MQMO_MATCH_MSG_ID;
mqGMO.Options = MQC.MQGMO_WAIT | MQC.MQGMO_NO_SYNCPOINT;
mqQueueReply.Get(mqMessageReply, mqGMO);
replyMessage += mqMessageReply.ReadString(mqMessageReply.DataLength); |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 10, 2006 10:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
MQPMO_NEW_MESSAGE_ID controls whether or not the MQ Put generates a new message id.
It is always better to allow MQ to generate the message id, but that doesn't stop developers from building in weird dependancies on custom data in the message id.
So if you've inherited both ends of the process, then you can change the requester app and the server app to use an MQ generated id. Otherwise, you should not change this unless you verify with the server app that it will be okay. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wfudeac92 |
Posted: Wed May 10, 2006 10:32 am Post subject: |
|
|
Novice
Joined: 24 Apr 2006 Posts: 21
|
Here are the only MQPMO options that I am using.
MQC.MQPMO_NO_SYNCPOINT | MQC.MQPMO_SET_IDENTITY_CONTEXT;
Is it safe to say that if the MessageID field is always set by the developer, then a new MessageID is not generated by MQ? |
|
Back to top |
|
 |
wfudeac92 |
Posted: Wed May 10, 2006 10:34 am Post subject: |
|
|
Novice
Joined: 24 Apr 2006 Posts: 21
|
Here are the only MQPMO options that I am using.
MQC.MQPMO_NO_SYNCPOINT | MQC.MQPMO_SET_IDENTITY_CONTEXT;
Is it safe to say that if the MessageID field is always set by the developer, then a new MessageID is not generated by MQ? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 10, 2006 10:40 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
wfudeac92 wrote: |
Is it safe to say that if the MessageID field is always set by the developer, then a new MessageID is not generated by MQ? |
Does that fit with the what the documentation on MQPMO_NEW_MSG_ID says? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wfudeac92 |
Posted: Wed May 10, 2006 11:19 am Post subject: |
|
|
Novice
Joined: 24 Apr 2006 Posts: 21
|
Here is what I found out. If you specify your own MsgID the queue manager will not overwrite that value. If you do now specify a value the following occurs to generate the MsgId.
A MsgId generated by the queue manager consists of a 4-byte product identifier (AMQ or CSQ in either ASCII or EBCDIC, where represents a blank), followed by a product-specific implementation of a unique string. In WebSphere MQ this contains the first 12 characters of the queue-manager name, and a value derived from the system clock. All queue managers that can intercommunicate must therefore have names that differ in the first 12 characters, in order to ensure that message identifiers are unique. The ability to generate a unique string also depends on the system clock not being changed backward. To eliminate the possibility of a message identifier generated by the queue manager duplicating one generated by the application, the application must avoid generating identifiers with initial characters in the range A through I in ASCII or EBCDIC (X'41' through X'49' and X'C1' through X'C9'). However, the application is not prevented from generating identifiers with initial characters in these ranges. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 10, 2006 11:36 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzak.doc/js01791.htm wrote: |
MQPMO_NEW_MSG_ID
The queue manager replaces the contents of the MsgId field in MQMD with a new message identifier. This message identifier is sent with the message, and returned to the application on output from the MQPUT or MQPUT1 call.
This option can also be specified when the message is being put to a distribution list; see the description of the MsgId field in the MQPMR structure for details.
Using this option relieves the application of the need to reset the MsgId field to MQMI_NONE prior to each MQPUT or MQPUT1 call.
This option is supported on all WebSphere MQ V6.0 systems. |
So if you specify your own MsgID, AND specify MQPMO_NEW_MSG_ID, then your ID will not be used. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wfudeac92 |
Posted: Wed May 10, 2006 12:00 pm Post subject: |
|
|
Novice
Joined: 24 Apr 2006 Posts: 21
|
That appears to be the case. Thanks for pointing me in the right direction. |
|
Back to top |
|
 |
|