Author |
Message
|
Yash1234 |
Posted: Mon Oct 02, 2006 3:24 pm Post subject: Custom Message ID |
|
|
Newbie
Joined: 02 Oct 2006 Posts: 8
|
Hi,
I have basic knowledge about the way MQ works & am designing a system that will use MQ to communicate with more then one system.
What I want to know is whether we can define Custom MQ message id ?? The reason I'm looking for this is, my system will read the message from a Queue (Q1), put by other systems. After processing the message will generate a reply message & I want to put this reply message to a reply Queue (Q2) with the same message id so that the requesting system can read the reply message from this queue (Q2) using the message id it has.
Any help on this will be of greate use.
Regards,
Yash |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Oct 02, 2006 8:22 pm Post subject: Re: Custom Message ID |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Yash1234 wrote: |
What I want to know is whether we can define Custom MQ message id ?? The reason I'm looking for this is, my system will read the message from a Queue (Q1), put by other systems. After processing the message will generate a reply message & I want to put this reply message to a reply Queue (Q2) with the same message id so that the requesting system can read the reply message from this queue (Q2) using the message id it has. |
No. No. No! Use the Correlation Id and do not try to create a Custom Message Id.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
Vitor |
Posted: Tue Oct 03, 2006 12:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Let me endorse and emphasise the comments of my most worthy associate - yours is a bad idea!
Do not try and generate Message Ids. I've seen it attempted before and it's a one-way road to pain, misery and application errors. Use the mechanisms IBM have supplied and save yourself a lot of trouble! _________________ Honesty is the best policy.
Insanity is the best defence.
Last edited by Vitor on Tue Oct 03, 2006 6:19 am; edited 1 time in total |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Oct 03, 2006 6:11 am Post subject: |
|
|
Guest
|
"I have basic knowledge about the way MQ works ..." Read the Application Programmers Reference about the MQMD (Message Descriptor) that accompanies the message throughout its life in MQ. Specifically, the MSGID and CORRELID. These two fields can be filled in by the programmer or qmgr.
IBMs suggested method of associating the request message with the reply is for the requesting application to request the qmgr generate a new and unique MSGID at MQPUT time. The replying program gets the request message, moves the inbound MSGID to the CORRELID field of the reply message at MQPUT time.
Again, you can used both fields for whatever you want; but the IBM-suggested method works perfectly. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 03, 2006 6:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
bruce2359 wrote: |
Again, you can used both fields for whatever you want; |
As long as each field only holds 24 bytes, and you do not ever expect any data conversion to occur, and you are not worried about having duplicate message ids passing through your system and you do not mind putting business level data into a transport level header, and your messages never pass to anything that is not specifically designed to handle your custom use of these fields and ... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Oct 03, 2006 6:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Vitor wrote: |
Use the mechanisms IBM have supplied and save yourself a lot of trouble! |
Ok, less scenarios than the Grand Poobah but exactly the sort of thing I was getting at!
It's a very serious wheel to try and reinvent. It can be done, but I've never seen a stable home grown solution that wasn't abandoned by integration testing at least. The sugested IBM solution is the best, and user data in the MQMD should be limited to those fields intended for the purpose.
Or exiled to the RFH2.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Yash1234 |
Posted: Tue Oct 03, 2006 9:34 am Post subject: |
|
|
Newbie
Joined: 02 Oct 2006 Posts: 8
|
Thanks for the Response.
What I concluded with the discussion above is, instead of MessageId I should be using CorrelationId, I think I should look at the sample example of how to use this as I'm still not clear how I get the scenrio I want. My question is
1. When my client put a message on MQ, they get the message Id back. For them to get the correlation ID back do my MQ guy have to do any setting or my clients have to add some extra code to get it back from MQ ?
2. When I read the message put by my client, will I get the correlation Id by default or do I have to do any setting in my code while reading the message ?
3. Can I use this correlationId to put the message on the reply queue so that my client can pick up message from there ? (the reply queue is different from the queue where my client put message)
4. Can my client use the correlation ID that they got when they put the message, to read the message from the reply Queue (remember my client have a different reply queue, not same as where they put message).
Your Answers will be of great help.
Thanks,
Yash |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 03, 2006 9:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The basic pattern is this.
The requesting application creates a new message, and specifies MQPMO_NEW_MSG_ID when it puts the request.
The replying application receives the message, copies MQMD.MsgId to MQMD.CorrelID in the reply and specifies MQPMO_NEW_MSG_ID when it sends the reply...
You can also use the Report options on the Request to specify how you want the replying application to handle your particular message - including instructing it to Pass the Msg ID, create a new one, Copy Msg ID to CorrelID, or Pass the CorrelId.
But the replying application has to be written to honor those options. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Oct 03, 2006 9:56 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Yash1234 wrote: |
Thanks for the Response.
What I concluded with the discussion above is, instead of MessageId I should be using CorrelationId, I think I should look at the sample example of how to use this as I'm still not clear how I get the scenrio I want. My question is
1. When my client put a message on MQ, they get the message Id back. For them to get the correlation ID back do my MQ guy have to do any setting or my clients have to add some extra code to get it back from MQ ?
2. When I read the message put by my client, will I get the correlation Id by default or do I have to do any setting in my code while reading the message ?
3. Can I use this correlationId to put the message on the reply queue so that my client can pick up message from there ? (the reply queue is different from the queue where my client put message)
4. Can my client use the correlation ID that they got when they put the message, to read the message from the reply Queue (remember my client have a different reply queue, not same as where they put message).
Your Answers will be of great help.
Thanks,
Yash |
All of this is detailed in the manual but simplistically:
Program A puts the message, setting the reply details as required & receiving the message ID back;
Program B reads the message, does what it does and puts a reply with the inbound message ID in the correlation ID (getting a new message ID but who cares?);
Program A reads the message from the reply queue using the message ID it got back from the put as a correlation ID
Simple eh?
There are all sorts of system features that assist with this sort of thing; I'll highlight the matching options on reading a message. The Application Guide lays all this out for you.
Happy Reading  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Yash1234 |
Posted: Tue Oct 03, 2006 10:00 am Post subject: |
|
|
Newbie
Joined: 02 Oct 2006 Posts: 8
|
Thanks for the reply. If this work then I think I got my solution. I will try this with a simple program.
Thanks!! |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Oct 03, 2006 10:07 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
|
Back to top |
|
 |
Yash1234 |
Posted: Tue Oct 03, 2006 3:37 pm Post subject: |
|
|
Newbie
Joined: 02 Oct 2006 Posts: 8
|
I tested the MQ with a sample code & it all worked fine. Thanks for All the help !!!!
Regards,
Yash |
|
Back to top |
|
 |
|