|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
OPEN VMS MQ GET issue |
« View previous topic :: View next topic » |
Author |
Message
|
farriz |
Posted: Fri Dec 17, 2010 11:42 am Post subject: OPEN VMS MQ GET issue |
|
|
Newbie
Joined: 17 Dec 2010 Posts: 4
|
The issue I have is I do not know the length of the message. Iam doing a MQget with a buffer length of 1 so that it will fail but it will also get me the message length. Once I get the message length I want to do an another get with the same Msg id but with the buffer length from the previous get. Iam getting a 2186 Error code on my second get.
This is my code which shows my first get and the second get.
Code: |
gmo.Version = MQGMO_VERSION_2; /* Avoid need to reset Message */
gmo.MatchOptions = MQMO_NONE; /* ID and Correlation ID after */
/* every MQGET */
gmo.Options = MQGMO_WAIT /* wait for new messages */
+ MQGMO_CONVERT; /* convert if necessary */
gmo.WaitInterval = 15000; /* 15 second limit for waiting */
buflen = sizeof(buffer) - 1; /* buffer size available for GET */
memset(buffer,' ',buflen);
/****************************************************************/
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
tempcon = Hcon;
tempobj = Hobj;
printf("Hcon on the 1 get %ld\n", Hcon);
printf("Hobj on the 1 get %ld\n", Hobj);
/****************************************************************/
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* buffer length */
buffer, /* message buffer */
&messlen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
if (Reason != MQRC_NONE)
printf("buffer length 1ST GET %ld\n", buflen);
{
if (Reason == MQRC_NO_MSG_AVAILABLE)
{ /* special report for normal end */
CompCode = MQCC_FAILED;
trnccode = (int) Reason;
printf("no more messages\n");
}
else /* general report for other reasons */
{
printf("MQGET 1 ended with reason code %ld\n", Reason);
/* treat truncated message as a failure for this sample */
if (Reason == MQRC_TRUNCATED_MSG_FAILED)
{
gmo.Version = MQGMO_VERSION_2; /* Avoid need to reset Message */
gmo.Options = MQGMO_WAIT /* wait for new messages */
+ MQGMO_CONVERT; /* convert if necessary*/
gmo.WaitInterval = 15000; /* 15 second limit for waiting */
buflen = messlen;
printf("buffer length 2ND GET %ld\n", buflen);
memset(buffer,' ',buflen);
printf("Message ID on the 1 get %ld\n", md.MsgId);
printf("buffer length %s\n", buffer);
/** specify representation that is required **/
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
memcpy(messgid, md.MsgId, sizeof(md.MsgId));
memcpy(md.MsgId, messgid, sizeof(messgid));
Hcon = tempcon;
Hobj= tempobj;
/****************************************************************/
printf("Hcon on the 2 get %ld\n", Hcon);
printf("Hobj on the 2 get %ld\n", Hobj);
printf("Message ID on the 2 get %ld\n", md.MsgId);
/*memcpy(gmo.StrucId,MQGMO_STRUC_ID,sizeof(gmo.StrucId));*/
gmo.MatchOptions = MQMO_MATCH_MSG_ID;
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* buffer length */
buffer, /* message buffer */
&messglen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
printf("Message ID on the 2 after get %ld\n", md.MsgId);
if (Reason != MQRC_NONE)
{
if (Reason == MQRC_NO_MSG_AVAILABLE)
{ /* special report for normal end */
CompCode = MQCC_FAILED;
trnccode = (int) Reason;
printf("no more messages\n");
}
else /* general report for other reasons^
{
printf("MQGET ended with reason code %ld\n", Reason);
CompCode = MQCC_FAILED;
trnccode = (int) Reason;
}
} |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Dec 17, 2010 11:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Excellent 1st post and to the point. As it is your first post I enclosed your code within the "code" tags for you. It saves the formatting and makes for easier reading. Please be mindful of this in the future. I hope one of our mainframers will be along shortly and able to give you an answer.
A word about best practice... It is considered best practice to have a buffer of the size of the average message and only increase when needed (as you do here)/ decrease when you truly have a "one off" big message.  _________________ MQ & Broker admin
Last edited by fjb_saper on Fri Dec 17, 2010 12:02 pm; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 17, 2010 11:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
3 points:
- Please use "code" tags when posting code; makes it easier to read
- Why not do a single get with the buffer set to the maximum message length?
- Is this the complete code? Is there anything between the 2 gets which could be corrupting the gmo area? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Dec 17, 2010 12:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you do a get with Translate option. Don't know what CCSID your qmgr is declared with. Be mindful of the consequences to msglen of a get with convert... (single byte to double byte char set ) etc ...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
farriz |
Posted: Fri Dec 17, 2010 12:13 pm Post subject: |
|
|
Newbie
Joined: 17 Dec 2010 Posts: 4
|
I have the open statements above this and close and disconnet after this . Also there is no code missing in between. |
|
Back to top |
|
 |
farriz |
Posted: Fri Dec 17, 2010 12:28 pm Post subject: |
|
|
Newbie
Joined: 17 Dec 2010 Posts: 4
|
Appreciate for tagging the code. In future I will do it. |
|
Back to top |
|
 |
Mr Butcher |
Posted: Sun Dec 19, 2010 11:18 pm Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
Quote: |
gmo.Version = MQGMO_VERSION_2; /* Avoid need to reset Message */ |
are you sure about that? IMHO you dont need to set the version as it is pre-set for your plattform.... dont know about vms, but whats the value in your mqgmo copybook (or however it is called in vms) _________________ Regards, Butcher |
|
Back to top |
|
 |
bruce2359 |
Posted: Mon Dec 20, 2010 7:28 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
It's also a best-practice to do NOT do two (MQGET) calls when one MQGET call will do.
Doing two calls (one to determine msg length, and create the appropriate buffer size; and one to finally get the message) trades additional I/O and processor cycles for virtual (and real) storage. This is wasteful and unnecessary. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|