|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
My MQGET Hanngs on Z/OS |
« View previous topic :: View next topic » |
Author |
Message
|
vignesh1988 |
Posted: Wed May 07, 2014 7:33 am Post subject: My MQGET Hanngs on Z/OS |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
Hello Everyone,
Need a help. The below is my code where i use SYSTEM.COMMAND.INPUT to process MQSC type commands, It's Executing Successfully and replies are coming under the SYSTEM.DEFAULT.LOCAL.QUEUE (QLOCAL) but my MQGET call hangs without picking messages from that.
Please assist.
Code: |
#include <memory.h>
#include <stdio.h>
#include <string.h>
/* Include MQSeries headers */
#include <cmqc.h>
#include <cmqcfc.h>
#include <cmqxc.h>
/* #Define Constants */
#define OK 1
#define FAIL 0
#define REPLYQ "SYSTEM.DEFAULT.LOCAL.QUEUE\0"
//#define REPLYQ "SYSTEM.DEFAULT.MODEL.QUEUE\0"
#define ADMINQ "SYSTEM.COMMAND.INPUT\0"
//#define ADMINQ "SYSTEM.ADMIN.COMMAND.QUEUE\0"
/* MQ Related Variables Declerations and Structure Variables Declerations */
MQOD ObjDesc = { MQOD_DEFAULT }; /* Object Descriptor Default Values */
MQMD md = { MQMD_DEFAULT }; /* Message Descriptor Default Values */
MQPMO pmo = { MQPMO_DEFAULT }; /* Put Message Options Default Values */
MQGMO gmo = { MQGMO_DEFAULT }; /* Get Message Options Default Values */
MQCNO Connect_options = {MQCNO_DEFAULT}; /* MQCONNX options */
MQCD ClientConn = {MQCD_CLIENT_CONN_DEFAULT}; /* Client connection channel */
void PutMsg( MQHCONN hConn /* Connection to queue manager */
, MQCHAR8 MsgFormat /* Format of user data to be put in msg */
, MQHOBJ hQName /* handle of queue to put the message to */
, MQCHAR48 QName /* name of queue to put the message to */
, char *UserMsg /* The user data to be put in the message */
, MQLONG UserMsgLen /* */
);
int GetMsg( MQHCONN hConn /* handle of queue manager */
, MQLONG MQParm /* Options to specify nature of get */
, MQHOBJ hQName /* handle of queue to read from */
, char *UserMsg /* Input/Output buffer containing msg */
, MQLONG ReadBufferLen /* Length of supplied buffer */
);
MQHOBJ OpenQ( MQHCONN hConn
, MQCHAR48 QName
, MQLONG OpenOpts
);
MQLONG iqmCompCode; /* Completion code */
MQLONG iqmReason; /* Reason code */
MQHCONN hConn; /* handle to connected queue mgr */
MQLONG idiscReason;
MQLONG idiscCompCode;
//############### As Per IBM - PMR 53938,442,000 ###############################
MQBYTE24 RequestMsgId;
//##################################################################
/* Temperory Buffers, Variables, Arrays, Pointers */
char QMgrName[30]={'\0'};
char HostName[MQ_CONN_NAME_LENGTH+1]={'\0'};
char ChannelName[MQ_CHANNEL_NAME_LENGTH+1]={'\0'};
char Temp1[50]={'\0'};
int Return_Code=0;
int MQVersion_Reason=0;
char Response_Buffer[2000]={'\0'};
/* Functional Routines */
int MQCONX();
int MQDISCONNECT();
int MQOBJECT_PROCESS();
int main()
{
Return_Code=MQCONX();
switch(Return_Code)
{
case 0: // MQCONNX Successful
Return_Code = MQOBJECT_PROCESS(); // Same Connection Handle used for CONNX
Return_Code = MQDISCONNECT();
break;
default:
printf("FAILED: The Code has Ended, , , , |");
break;
}
}
int MQCONX()
{
strncpy(ClientConn.ConnectionName,"mvsa580(1411)",MQ_CONN_NAME_LENGTH);
strncpy(ClientConn.ChannelName,"XBBJ605.CLIENT",MQ_CHANNEL_NAME_LENGTH);
Connect_options.ClientConnPtr = &ClientConn;
Connect_options.Version = MQCNO_VERSION_2;
MQCONNX("MQD1", /* queue manager */
&Connect_options, /* options for connection */
&hConn, /* connection handle */
&iqmCompCode, /* completion code */
&iqmReason); /* reason code */
/* report reason and stop if it failed */
if (iqmCompCode == MQCC_FAILED)
{
printf("FAILED: Failed on MQCONNX with the MQRC: %ld for Qmgr %s, , , , |", iqmReason,QMgrName);
return iqmReason; // MQCONNX Failure
}
return iqmReason;
}
int MQOBJECT_PROCESS()
{
MQOD ObjDesc; /* */
MQLONG OpenOpts; /* */
MQLONG CompCode; /* MQ API completion code */
MQLONG Reason; /* Reason qualifying above */
/* */
MQHOBJ hAdminQ; /* handle to output queue */
MQHOBJ hReplyQ; /* handle to input queue */
/* */
MQLONG AdminMsgLen, AdminMsgLen1; /* Length of user message buffer */
MQBYTE *pAdminMsg; /* Ptr to outbound data buffer */
MQCFH *pPCFHeader; /* Ptr to PCF header structure */
MQCFST *pPCFString; /* Ptr to PCF string parm block */
MQCFIN *pPCFInteger; /* Ptr to PCF integer parm block */
MQLONG *pPCFType; /* Type field of PCF message parm */
/* */
MQCHAR8 MsgFormat; /* Format of inbound message */
short Index; /* Loop counter */
char COMMAND[]="ALTER QLOCAL(XBBJ605.PCF1.QUEUE1) GET(DISABLED)";
char RESPONSE_MSG[15001]={'\0'};
MQLONG Message_Length,Return_Code;
Message_Length=strlen(COMMAND);
hAdminQ = OpenQ( hConn, ADMINQ, MQOO_OUTPUT );
hReplyQ = OpenQ( hConn, REPLYQ, MQOO_INPUT_SHARED );
PutMsg( hConn /* Queue manager handle */
, MQFMT_STRING /* Format of message */
, hAdminQ /* Handle of command queue */
, REPLYQ /* reply to queue */
, COMMAND /* Data part of message to put */
, Message_Length
);
gmo.Options = MQGMO_WAIT
| MQGMO_NO_SYNCPOINT
//| MQPMO_SYNCPOINT
| MQGMO_CONVERT;
do {
printf("\nMQGET Happening\n");
Return_Code=GetMsg( hConn
, gmo.Options
, hReplyQ
, RESPONSE_MSG
, 15001
);
printf("##################\n");
printf("#### %s ####\n",RESPONSE_MSG);
//}while ( Return_Code != MQCC_FAILED );
}while ( 1==0 );
return -1;
}
MQHOBJ OpenQ( MQHCONN hConn, MQCHAR48 QName, MQLONG OpenOpts)
{
MQHOBJ Hobj;
MQLONG CompCode, Reason;
ObjDesc.ObjectType = MQOT_Q;
strncpy(ObjDesc.ObjectName, QName, MQ_Q_NAME_LENGTH);
MQOPEN(hConn, /* connection handle */
&ObjDesc, /* object descriptor for queue */
OpenOpts, /* open options */
&Hobj, /* object handle */
&CompCode, /* MQOPEN completion code */
&Reason); /* reason code */
/* report reason, if any; stop if failed */
if (Reason != MQRC_NONE)
{
printf("FAILED: Failed on MQOPEN for %s with MQRC: %d, , , , |",QName,Reason);
if (iqmReason != MQRC_ALREADY_CONNECTED)
{
MQDISC(&hConn,
&iqmCompCode,
&iqmReason);
if (iqmReason != MQRC_NONE)
printf("FAILED: MQDISC ended with MQRC: %d, , , , |",iqmReason);
}
exit(-1);
}
return Hobj;
}
void PutMsg(MQHCONN hConn,
MQCHAR8 MsgFormat,
MQHOBJ hQName,
MQCHAR48 QName,
char *UserMsg,
MQLONG UserMsgLen)
{
MQLONG CompCode, Reason;
/* setup the message descriptor prior to putting the message */
md.Report = MQRO_NONE;
md.MsgType = MQMT_REQUEST;
md.Expiry = MQEI_UNLIMITED;
md.Feedback = MQFB_NONE;
md.Encoding = MQENC_NATIVE;
md.Priority = MQPRI_PRIORITY_AS_Q_DEF;
md.Persistence = MQPER_PERSISTENCE_AS_Q_DEF;
md.MsgSeqNumber = 1;
md.Offset = 0;
md.MsgFlags = MQMF_NONE;
md.OriginalLength = MQOL_UNDEFINED;
memcpy(md.GroupId, MQGI_NONE, sizeof(md.GroupId));
memcpy(md.Format, MsgFormat, sizeof(md.Format) );
memcpy(md.ReplyToQ, QName, sizeof(md.ReplyToQ) );
/* reset MsgId and CorrelId to get a new one */
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) ); // Specifying this, the qmgr will generate a New Message Identifier and put to the message descriptor
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );
/* set CorrelId to MsgId of request */
//memcpy(md.CorrelId, md.MsgId, sizeof(md.CorrelId) );
MQPUT(hConn, /* connection handle */
hQName, /* object handle */
&md, /* message descriptor */
&pmo, /* default options */
UserMsgLen, /* message length */
UserMsg, /* message buffer */
&CompCode, /* completion code */
&Reason); /* reason code */
//############### As Per IBM - PMR 53938,442,000 ###############################
memcpy(md.CorrelId, md.MsgId, sizeof(md.CorrelId) );
//##################################################################
if (Reason != MQRC_NONE) {
printf("FAILED: Failed on MQPUT in %s with MQRC: %d, , , , |",ADMINQ,Reason);
if (iqmReason != MQRC_ALREADY_CONNECTED)
{
MQDISC(&hConn,
&iqmCompCode,
&iqmReason);
if (iqmReason != MQRC_NONE)
printf("FAILED: MQDISC ended with MQRC: %d, , , , |",iqmReason);
}
exit(-1);
}
else
printf("MQPUT Reason = %d",Reason);
memcpy(RequestMsgId, md.MsgId, sizeof(md.MsgId));
}
int GetMsg(MQHCONN hConn, MQLONG MQParm, MQHOBJ hQName,
char *UserMsg, MQLONG ReadBufferLen)
{
MQLONG CompCode, Reason, msglen;
gmo.Options = MQParm;
gmo.WaitInterval = 9000;
/* reset MsgId and CorrelId to get a new one */
//memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
//memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );
/* reset MsgId to get a new one */
//memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
//gmo.MatchOptions = MQMO_MATCH_CORREL_ID;
//############### As Per IBM - PMR 53938,442,000 ###############################
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
memcpy(md.CorrelId, RequestMsgId, sizeof(md.CorrelId) );
gmo.MatchOptions = MQMO_MATCH_CORREL_ID;
//############### ##################################################
/* reset MsgId and CorrelId to get a new one */
/*memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );*/
printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
MQGET(hConn, /* connection handle */
hQName, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
ReadBufferLen, /* Buffer length */
UserMsg, /* message buffer */
&msglen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
if (Reason != MQRC_NONE) {
printf("FAILED: Failed on MQGET for %s with MQRC: %d, , , , |",REPLYQ,Reason);
if (iqmReason != MQRC_ALREADY_CONNECTED)
{
MQDISC(&hConn,
&iqmCompCode,
&iqmReason);
if (iqmReason != MQRC_NONE)
printf("FAILED: MQDISC ended with MQRC: %d, , , , |",iqmReason);
}
//Return_Code = Auth_Log_Write();
//exit(-1);
printf("Message Length : %d\n",msglen);
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
return Reason;
}
else
printf("MQGET Reason = %d",Reason);
return Reason;
}
int MQDISCONNECT()
{
if (iqmReason != MQRC_ALREADY_CONNECTED)
{
MQDISC(&hConn,
&idiscCompCode,
&idiscReason);
if (idiscReason != MQRC_NONE)
printf("FAILED: MQDISC ended with MQRC: %d, , , , |",iqmReason);
}
return 0;
}
|
|
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 8:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
DO NOT FOR ANY REASON USE THE SYSTEM QUEUES LIKE THIS!
SYSTEM.DEFAULT.LOCAL.QUEUE has a specific use and SYSTEM.COMMAND.INPUT (which I assume you've created or mistyped the name) will still be treated as system queue.
Especially on z/OS where the only way to get this working is a specific RACF rule which allows access and this will make a mockery of your security strategy.
It takes seconds to define your own queues. Invest the time.
The code you describe as "my" code looks a lot like an IBM sample to me.
It hangs because a) it's coded to and b) there's a bug further up. If this is "your" code, fix it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vignesh1988 |
Posted: Wed May 07, 2014 8:09 am Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
Thanks for your Reply..
SYSTEM.COMMAND.INPUT is Command server for Z/OS. I am passing my MQ Commands to it and retrieving a reply to a "Reply To Queue".
I will use my own queue itself. Still it hangs.
I read IBM manuals and developed this one. I can recognize that i made a mistake in Mapping MsgID and CorreID inoder to GET my message alone. But am unable to resolve it.
Can you please help me. Much Appreciated.
Thanks, Vignesh1988 |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 8:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
SYSTEM.COMMAND.INPUT is Command server for Z/OS. |
Is it? Not in my recollection but it's been a while
vignesh1988 wrote: |
I will use my own queue itself. Still it hangs. |
And in this new local queue you've created you can see the reply messages? With all the ids you're expecting to be present in the header?
vignesh1988 wrote: |
I read IBM manuals and developed this one. I can recognize that i made a mistake in Mapping MsgID and CorreID inoder to GET my message alone. But am unable to resolve it. |
It's still hanging because you've coded it that way, after your reasearch. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vignesh1988 |
Posted: Wed May 07, 2014 8:36 am Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
As per IBM 7.0 Manual, SYSTEM.COMMAND.INPUT is specified as MQ Command Server
The below is the reply messages sitting under the Queue created by me (XBBJ605.MODEL.QUEUE1 - LocalQ)
Code: |
,BROWSE QU QUEUE-XBBJ605.MODEL.QUEUE1 --------------- Line 00000000 Col 001 080,
,COMMAND ===>, ,SCROLL ===>,CSR ,
********************************* Top of Data **********************************
CSQN205I COUNT= 5, RETURN=0000000C, REASON=00000008
CSQM125I MQD1 CSQMAQLC QLOCAL(XBBJ605.PCF1.QUEUE1) QSGDISP(QMGR) WAS
NOT FOUND
CSQM090E MQD1 CSQMAQLC FAILURE REASON CODE X'00D44002'
CSQ9023E MQD1 CSQMAQLC ' ALTER QLOCAL' ABNORMAL COMPLETION
******************************** Bottom of Data ********************************
|
I really can't get these MsgId and CoreId issues. I couldn't resolve this
Can you please help me.. |
|
Back to top |
|
 |
PaulClarke |
Posted: Wed May 07, 2014 8:50 am Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
There are more problems with this code than I would like to share.
Perhaps what you should do is write the code on a platform with a good source debugger and step through the code.
MQ is great for it's platform independence. One thing to be a little careful of is default syncpoint which, sadly, is different between z/OS and Distributed. Regardless in general it's always a good idea to explicitly say which syncpoint you want to use. You seem to have done this for MQGET but I don't see it for MQPUT. I would have thought that that in itself would be one problem and could appear like a hang. Not specifying how you want the command server to handle msgid/correlid would be another problem, excessive use of global variables another, not handling orphan messages another etc etc.
Hope this helps in some small way.
Paul _________________ Paul Clarke
MQGem Software
www.mqgem.com
Last edited by PaulClarke on Wed May 07, 2014 11:51 am; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 8:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
As per IBM 7.0 Manual, SYSTEM.COMMAND.INPUT is specified as MQ Command Server |
As you say.
vignesh1988 wrote: |
I really can't get these MsgId and CoreId issues. |
It would help if you were looking at the message id or correlation id. My memory of how you do that through ISPF is as clear as my memory of the command queue name; I'm sure the manual talks about it.
vignesh1988 wrote: |
I couldn't resolve this |
You don't seem to be giving yourself enough data to resolve this, and you're certainly not posting enough. The first move is to determine if the messaage in the queue is correctly identified as the reply to your request. Having done that, you can then proceed to correct the code bug or the identity bug, as appropriate. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vignesh1988 |
Posted: Wed May 07, 2014 8:54 am Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
That's what i posted before..
The Reply Messages are correctly coming to the Reply-To-Queue and staying.
But i couldn't MQGET that.
Please assist. |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 9:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
But i couldn't MQGET that. |
Yes, I got that.
vignesh1988 wrote: |
Please assist. |
As I said, that's impossible from the information provided. For you or for me. You need to do more investigation. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vignesh1988 |
Posted: Wed May 07, 2014 9:03 am Post subject: |
|
|
Acolyte
Joined: 13 Apr 2013 Posts: 62 Location: Chennai
|
Ok, Thanks.
What more information you need from me?? Advise.
Do you need the complete code? (But I posted above) |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 9:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vignesh1988 wrote: |
What more information you need from me?? |
The ids from the header, and the ids your code is expecting. Without those, there's no proof that this is a code problem. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed May 07, 2014 10:33 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi Vignesh,
I don't know how to say this politely, so I won't bother. Your code is garbage.
- What is with all of the global variables? (Vitor, slap him with a fish).
- Second, why are you using a SYSTEM queue for a reply queue? (Vitor, please ...).
- Third, why aren't you using a temporary dynamic queue as per the MQ documentation?
- Fourth, you have included PCF structures but never used them.
- Fifth, you set WaitInterval but never set the MQGMO_WAIT option then you complain it is waiting forever - gee I wonder why.
- Sixth, the ALTER command you are issuing is for a queue that does NOT exist in that particular queue manager ('MQD1'), as the error message clearly says:
vignesh1988 wrote: |
Code: |
CSQM125I MQD1 CSQMAQLC QLOCAL(XBBJ605.PCF1.QUEUE1) QSGDISP(QMGR) WAS NOT FOUND
|
|
- Seventh, none of your MQ API calls use *_FAIL_IF_QUIESCING option - bad, very bad design.
At this point, I'm just going to stop because I am getting really annoyed looking at the code.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2014 11:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Yes it's not pretty. I was trying for the "getting it working" before I brought out the Trout Of Teaching for style.
But yes. And I did mention the SYSTEM queue thing already. In bold. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed May 07, 2014 4:10 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 07, 2014 5:57 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
RogerLacroix wrote: |
If you find the code useful, then please sign up for MQTC v2.0.1.4
Regards,
Roger Lacroix
Capitalware Inc. |
Quite unlikely unless you plan to have it held in India. His location states Chennai...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
Goto page 1, 2 Next |
Page 1 of 2 |
|
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
|
|
|
|