Author |
Message
|
Sathiyendran |
Posted: Fri Jul 17, 2015 2:25 am Post subject: Need to send MsgId and CorreId to another system |
|
|
Newbie
Joined: 17 Jul 2015 Posts: 5
|
Need to send a msg to the another system and also looking for the corresponding response back to the source system
MOVE MQMT-REQUEST TO MQMD-REQUEST-TYPE
MOVE MQMI-NONE TO MQMD-MSD-ID
MOVE MQCI-NONE TO MQMD-CORREID
Anyone suggest and provide an idea to generate unique MsgId and CorreId for the new message to the request MQ and also how to send a reply back to source system with the help of MsgId and CorreId received. |
|
Back to top |
|
 |
exerk |
Posted: Fri Jul 17, 2015 3:48 am Post subject: Re: Need to send MsgId and CorreId to another system |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Sathiyendran wrote: |
Anyone suggest and provide an idea to generate unique MsgId and CorreId for the new message to the request MQ and also how to send a reply back to source system with the help of MsgId and CorreId received. |
I believe the convention is to leave MQ to generate a MsgId for your request message, which you then trap, and for the receiving application to extract the MsgId from your message, and plug into the CorrelId field of the reply message. You would then do a get-message-by-CorrelId on the reply-to-queue, using the MQ-generated MsgId you trapped as the index. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Last edited by exerk on Wed Jul 22, 2015 2:32 am; edited 1 time in total |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 17, 2015 4:55 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you looked at the samples?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Sathiyendran |
Posted: Fri Jul 17, 2015 9:31 am Post subject: Need to send MsgId and CorreId to another system |
|
|
Newbie
Joined: 17 Jul 2015 Posts: 5
|
Thanks for your replies.
Please clarify the below - We will not known the MsgId/CorreId till MQPUT/MQPUT1 call execute. let we assume that we have written 10 requests and receiving apps send the response for 6 requests only then how do we want to retrieve the response from the reply MQ because we dont have the MsgId/CorreId.
Please correct me if I'm wrong.
Also I saw some example like in Put Message Option we will be able to add MQPMO_NEW_MSG_ID and MQPMO_NEW_CORREL_ID. Again there are numeric values are added in PMO.
Please provide if you have any examples - We need to write some message and need to retrieve the corressponding response from reply MQ |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jul 17, 2015 9:34 am Post subject: Re: Need to send MsgId and CorreId to another system |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sathiyendran wrote: |
Please clarify the below - We will not known the MsgId/CorreId till MQPUT/MQPUT1 call execute. let we assume that we have written 10 requests and receiving apps send the response for 6 requests only then how do we want to retrieve the response from the reply MQ because we dont have the MsgId/CorreId.
Please correct me if I'm wrong. |
You're wrong.
Look at the samples as suggested.
You don't have the MsgId/CorrelId until the MQPut / MQPut1 call executes. Then you do have it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Sathiyendran |
Posted: Wed Jul 22, 2015 1:26 am Post subject: Sample Code written |
|
|
Newbie
Joined: 17 Jul 2015 Posts: 5
|
This was the code written to send a message to another application.
MOVE WS-QUEUE-ALIAS TO MQOD-OBJECTNAME.
MOVE WS-REPLY-QUEUE-ALIAS TO MQMD-REPLYTOQ
MOVE SPACES TO MQMD-REPLYTOQMGR
MOVE MQMT-REQUEST TO MQMD-MSGTYPE
MOVE MQMI-NONE TO MQMD-MSGID
MOVE MQMI-NONE TO MQMD-CORRELID
MOVE MQPER-PERSISTENT TO MQMD-PERSISTENCE.
COMPUTE MQPMO-OPTIONS = MQPMO-SYNCPOINT
+ MQPMO-NEW-MSG-ID
+ MQPMO-NEW-CORREL-ID
+ MQPMO-FAIL-IF-QUIESCING.
DISPLAY 'NEW MSG ID : ' MQMD-MSGID
DISPLAY 'NEW COR ID : ' MQMD-CORRELID
CALL 'MQPUT1' USING MQ-HCONN,
MQ-OBJ-DESCRIPTOR,
MQ-MSG-DESCRIPTOR,
MQ-PUT-OPTIONS,
MQ-MESSAGE-LENGTH,
MQ-MESSAGE-DATA,
MQ-COMPLETION-CODE,
MQ-REASON.
Please review and update whether the above code will generate MsgId and correlId and sent to another app. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jul 22, 2015 1:59 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Have you tried the code?
What happens?
Have you browsed the messages before the reciever reads the message AND again before the reply is Read?
Are the MQMD and CORRELID fields in the MQ header as you expect? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
zpat |
Posted: Wed Jul 22, 2015 2:09 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Always clear the msgid/correlid fields in the MQMD buffer, between every MQPUT (if doing more than one).
Otherwise they will get re-used and you won't get unique msgids. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jul 22, 2015 4:36 am Post subject: Re: Sample Code written |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sathiyendran wrote: |
Please review and update whether the above code will generate MsgId and correlId and sent to another app. |
Yes it will.
As my worthy associates point out, if you don't have some code before you do the get of the reply, you'll use the wrong ids. Likewise the DISPLAY statements are in the wrong place and are the reason you think you're not generating message ids.
Look at the sample code _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Sathiyendran |
Posted: Thu Jul 23, 2015 12:07 am Post subject: |
|
|
Newbie
Joined: 17 Jul 2015 Posts: 5
|
Thank you for all your replies.
I am not yet tried to read the message. Let me try that and post here whether MQ header have the MsgId and correlId or not.
Also I will make sure to clear those fields before writing new message to the MQ |
|
Back to top |
|
 |
tczielke |
Posted: Thu Jul 23, 2015 4:08 am Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
One note, you don't need to reset the MsgId or CorrelId before each PUT, if you use the MQPMO_NEW_MSG_ID or MQPMO_NEW_CORREL_ID PMO options. This is documented in the MQ manual, and is also explained in the amqsput0.c sample (snippet below);
Code: |
/******************************************************************/
/* Use these options when connecting to Queue Managers that also */
/* support them, see the Application Programming Reference for */
/* details. */
/* The MQPMO_NEW_MSG_ID option causes the MsgId to be replaced, */
/* so that there is no need to reset it before each MQPUT. */
/* The MQPMO_NEW_CORREL_ID option causes the CorrelId to be */
/* replaced. */
/******************************************************************/
/* pmo.Options |= MQPMO_NEW_MSG_ID; */
/* pmo.Options |= MQPMO_NEW_CORREL_ID; */
|
_________________ Working with MQ since 2010. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 23, 2015 5:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sathiyendran wrote: |
Let me try that and post here whether MQ header have the MsgId and correlId or not. |
It will. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|