Author |
Message
|
URPradhan |
Posted: Tue May 10, 2011 3:17 am Post subject: Set message properties using C (MQSETMP) |
|
|
Novice
Joined: 05 May 2011 Posts: 14
|
Hi Friends
I saw the sample program 'amqsstma.c' to set the message properties using the C API, MQSETMP. The function gets called for each property and value to be set on the message in the while loop.
But, after setting the message properties in the above while loop, why the function MQSETMP has been called again during sending the message in the put message section of the code ??? I'm confused here.
Please help me to understand the reason to call the MQSETMP again in the put message section of the code.
Thank you. |
|
Back to top |
|
 |
mvic |
Posted: Tue May 10, 2011 4:51 am Post subject: Re: Set message properties using C (MQSETMP) |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
URPradhan wrote: |
Please help me to understand the reason to call the MQSETMP again in the put message section of the code. |
Take another look. What is your current opinion of its purpose there in the code? |
|
Back to top |
|
 |
URPradhan |
Posted: Tue May 10, 2011 10:51 am Post subject: Re: Set message properties using C (MQSETMP) |
|
|
Novice
Joined: 05 May 2011 Posts: 14
|
mvic wrote: |
Take another look. What is your current opinion of its purpose there in the code? |
It seems that, the MQSETMP in the put message section of the code is setting another message property "Root.MQMD.Format". But why ? |
|
Back to top |
|
 |
mvic |
Posted: Tue May 10, 2011 12:20 pm Post subject: Re: Set message properties using C (MQSETMP) |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
URPradhan wrote: |
But why ? |
Well, it's a good question. I'm not really sure.
I do notice this comment immediately above the code we're talking about.
Code: |
/* Set the format in the message descriptor to MQFMT_STRING */
/* (character string format). */ |
So it says it is setting a format string, but this is normally done via the Format field in the MQMD.
I'll see if I can find out more. |
|
Back to top |
|
 |
mvic |
Posted: Tue May 10, 2011 12:43 pm Post subject: Re: Set message properties using C (MQSETMP) |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
mvic wrote: |
I'll see if I can find out more. |
OK I answered my own question.
Looking down a few lines, there is a call to MQPUT, passing NULL as the message descriptor.
There is therefore no MQMD, and so no MQMD.Format, being passed directly into the MQPUT call. So it looks like the Property named "Root.MQMD.Format" is being used to pass a format that would normally be included in the MQMD.Format.
What I also ought to have noticed earlier are the two (highly relevant) comments in the same sample code:
Code: |
/* Note: This program uses the message descriptor within the */
/* message handle to set the Format of the message. To use */
/* the message descriptor parameter of the MQPUT call see */
/* lines marked @@@@. */ |
Code: |
/* @@@@ Use the following line to set the Format field of the */
/* stack variable message descriptor. That variable will */
/* then need to be passed into the MQPUT call below. */
/* memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH); */ |
|
|
Back to top |
|
 |
URPradhan |
Posted: Tue May 10, 2011 9:17 pm Post subject: |
|
|
Novice
Joined: 05 May 2011 Posts: 14
|
Thank you mvic for your continuing support.
What I understood essentially is that, to set the message format to MQFMT_STRING the code is using the MQSETMP again.
If we would have used the declared stack variable for MQMD, ie, md and would have set the format with "memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH);", then there would have no need to call the MQSETMP function again. Please correct me. |
|
Back to top |
|
 |
gbaddeley |
Posted: Tue May 10, 2011 9:48 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
URPradhan wrote: |
...If we would have used the declared stack variable for MQMD, ie, md and would have set the format with "memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH);", then there would have no need to call the MQSETMP function again. |
Correct, but the purpose of this sample code was to show how to set MQMD fields using MQSETMP, and obviate the need for a separate MQMD variable. _________________ Glenn |
|
Back to top |
|
 |
URPradhan |
Posted: Tue May 10, 2011 10:21 pm Post subject: |
|
|
Novice
Joined: 05 May 2011 Posts: 14
|
gbaddeley wrote: |
Correct, but the purpose of this sample code was to show how to set MQMD fields using MQSETMP, and obviate the need for a separate MQMD variable. |
Great !
Thank you gbaddeley and mvic. |
|
Back to top |
|
 |
|