ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Security » MQRC 3014 on MQCMD_SET_AUTH_REC

Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 MQRC 3014 on MQCMD_SET_AUTH_REC « View previous topic :: View next topic » 
Author Message
vignesh1988
PostPosted: Mon Apr 14, 2014 7:56 am    Post subject: Reply with quote

Acolyte

Joined: 13 Apr 2013
Posts: 62
Location: Chennai

But below isn't correct ones..

Code:

void GetMsg(MQHCONN hConn, MQLONG MQParm, MQHOBJ hQName,
                  MQBYTE *UserMsg, MQLONG ReadBufferLen)
{
   MQLONG CompCode, Reason, msglen;

   gmo.Options      = MQParm;
   gmo.WaitInterval = 9000000;

   /* 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) );

   MQGET(hConn,             /* connection handle                */
         hQName,            /* object handle                    */
         &md,               /* message descriptor               */
         &gmo,              /* get message options              */
         ReadBufferLen,     /* Buffer length                    */
         (MQBYTE *)UserMsg, /* message buffer                   */
         &msglen,           /* message length                   */
         &CompCode,         /* completion code                  */
         &Reason);          /* reason code                      */

   if (Reason != MQRC_NONE) {
      printf("MQGET ended with Reason Code %d and Comp Code %d\n",
                     Reason, CompCode);
Back to top
View user's profile Send private message Send e-mail
jcv
PostPosted: Mon Apr 14, 2014 8:01 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

Exactly, this gets in FIFO manner, which is something you don't want.
Back to top
View user's profile Send private message Visit poster's website
vignesh1988
PostPosted: Mon Apr 14, 2014 8:02 am    Post subject: Reply with quote

Acolyte

Joined: 13 Apr 2013
Posts: 62
Location: Chennai

Can you please advise how to modify it??

Can you add what needs to be done..
Back to top
View user's profile Send private message Send e-mail
jcv
PostPosted: Mon Apr 14, 2014 11:30 pm    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

Hello Vignesh, how are you today? Not too stressed I hope, and ready to resume our adventure in the fascinating world of PCF messages.

So let's review a bit how to resolve this WTF, and then we will deal with the rest of them, and there were a plenty of them. First, I think that the cause of stale messages in a reply queue was debugger offer to walk me through some machine code, which I declined several times. Instead of trying to build that staff and set it up the way that would enable me to walk through your source, I simply compared the differences between your versions and saw the realloc that was causing me those Unhandled exceptions and Access violations. So I guess during some of these interrupted executions, a message was sent to command server, but its responses were not picked up. This situation is likely only during the development phase, but I still think that correlating response with the request is a very good idea. That is, if command server responds this way at all, by setting the correlID according to request messageID, which I also didn't check, otherwise it would be a bad idea. So why don't you check this and get back to me with some info first. Another possible source of similar problem is the fact that your GMO's don't enforce logical order, that is message sequence of responses. So if for some reason you get the message that has MQCFC_LAST in the control flag before those that have MQCFC_NOT_LAST, you will actually not consume them. I'm pretty much sure that my reply q was empty before I started this session with you, so some garbage must have been created like this.
Back to top
View user's profile Send private message Visit poster's website
jcv
PostPosted: Tue Apr 15, 2014 1:50 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

... and you have actually at disposal not one but two message sequence numbers, one in a PCF header, and another in a MD, but you don't use any of them when handling responses, as far as I can see. Is this supposed to be so?
Back to top
View user's profile Send private message Visit poster's website
jcv
PostPosted: Tue Apr 15, 2014 10:18 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

I checked by myself my assumption, and it turned out to be reasonable. This code solves that inaccuracy:

Code:

void PutMsg(MQHCONN hConn,
                  MQCHAR8 MsgFormat,
                  MQHOBJ hQName,
                  MQCHAR48 QName,
                  MQBYTE *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) );

   MQPUT(hConn,             /* connection handle                */
         hQName,            /* object handle                    */
         &md,               /* message descriptor               */
         &pmo,              /* default options                  */
         UserMsgLen,        /* message length                   */
         (MQBYTE *)UserMsg, /* message buffer                   */
         &CompCode,         /* completion code                  */
         &Reason);          /* reason code                      */

   /* set CorrelId to MsgId of request */
   memcpy(md.CorrelId, md.MsgId, sizeof(md.CorrelId) );

   if (Reason != MQRC_NONE) {
      printf("MQPUT ended with with Reason Code %d and Comp Code %d\n",
                     Reason, CompCode);
   if (iqmReason != MQRC_ALREADY_CONNECTED)
    {
        MQDISC(&hConn,
        &iqmCompCode,
        &iqmReason);

        if (iqmReason != MQRC_NONE)
            printf("MQDISC ended with reason code %d\n", iqmReason);
    }
      exit( -1 );
   }
   printf("MQPUT Call Reason = %d, CC = %d\n",Reason,CompCode);
   printf("***********************************************************************\n");
}

void GetMsg(MQHCONN hConn, MQLONG MQParm, MQHOBJ hQName,
                  MQBYTE *UserMsg, MQLONG ReadBufferLen)
{
   MQLONG CompCode, Reason, msglen;

   gmo.Options      = MQParm;
   gmo.WaitInterval = 9000000;

   /* reset MsgId to get a new one  */
   memcpy(md.MsgId,    MQMI_NONE, sizeof(md.MsgId) );

   MQGET(hConn,             /* connection handle                */
         hQName,            /* object handle                    */
         &md,               /* message descriptor               */
         &gmo,              /* get message options              */
         ReadBufferLen,     /* Buffer length                    */
         (MQBYTE *)UserMsg, /* message buffer                   */
         &msglen,           /* message length                   */
         &CompCode,         /* completion code                  */
         &Reason);          /* reason code                      */

   if (Reason != MQRC_NONE) {
      printf("MQGET ended with Reason Code %d and Comp Code %d\n",
                     Reason, CompCode);
   if (iqmReason != MQRC_ALREADY_CONNECTED)
    {
        MQDISC(&hConn,
        &iqmCompCode,
        &iqmReason);

        if (iqmReason != MQRC_NONE)
            printf("MQDISC ended with reason code %d\n", iqmReason);
    }
      exit( -1 );
   }
   printf("MQGET Call Reason = %d, CC = %d\n",Reason,CompCode);
   printf("***********************************************************************\n");
}



That way no junk in a reply q can affect response handling. With respect to message sequence, that inaccuracy is smaller and gets corrected after one execution without any code change.
Back to top
View user's profile Send private message Visit poster's website
jcv
PostPosted: Wed Apr 16, 2014 12:05 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

Obviously, this WTF has nothing to do with that WTF that is present in the very original code that you posted here (or maybe in command server, but exposed by your code, I can't tell exactly without further investigation that I don't intend to do) due to which we saw response pPCFHeader->Reason and pPCFHeader->CompCode both zero on unsuccessful command completion, since there is now definitely no junk in a reply q, and I still observe this when I run that code. Maybe you will post here the findings of that PMR that you opened.
Back to top
View user's profile Send private message Visit poster's website
vignesh1988
PostPosted: Wed Apr 16, 2014 12:47 am    Post subject: Reply with quote

Acolyte

Joined: 13 Apr 2013
Posts: 62
Location: Chennai

IBM hasen't replied yet for my question on response messages...

Also i applied the changes you posted on the GET/PUT routines.
What i did to check is:

I put 2 to 3 messages manually to the reply queue outside the code.
Then i executed my code and i could see the authorities were successfully issued on the profile and code ended normally.
But the current depth of my queue was 4 (3 Old msgs by me + 1 new message). My question here is why is the new message not be taken out from the queue.. though i get the O/P correctly.. Is it more than 2 responses received ?? so that i read the 1st message and leave the other in the queue itself?

Also i cleared the reply queue and executed once again, the code ended normally with no messages in the reply queue.

can you comment on this???

Also i am planning to generate DYNAMIC Queues on MQOPEN call by specifying the Model queue. But on the ReplyToQ field on MQPUT, IBM clearly said that "We cannot use Model Queue for ReplyToQ".
So how can be make the response GET on a Dynamic Queue since my team will be using this code for authority giving. So many can use the Same Reply Queue. So i gave MQOPEN option as MQOT_INPUT_SHARED.

Please assist me here..
Back to top
View user's profile Send private message Send e-mail
jcv
PostPosted: Wed Apr 16, 2014 2:09 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

Yes I can comment on that: Whatever I do, it always consumes all messages sent from command server. And only those.
Back to top
View user's profile Send private message Visit poster's website
vignesh1988
PostPosted: Wed Apr 16, 2014 2:33 am    Post subject: Reply with quote

Acolyte

Joined: 13 Apr 2013
Posts: 62
Location: Chennai

JCV,

Thanks, But.... ...
I didnt get your code on Matching the MSGID and the Corelation ID. Can you please explain me.

I used your code , i see the messages are still not identified as per Msg ID/Cor ID since for the 1st run, it's working fine. For the second run, it's giving the 1st message details and 2nd message detail also.

Can you assist me.
Back to top
View user's profile Send private message Send e-mail
jcv
PostPosted: Wed Apr 16, 2014 6:36 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

I don't understand exactly what you're reporting now, and the code that I posted works well on my machine even like that, although that wasn't exactly what I wanted. You had identical code in both functions:

Code:

   /* 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) );


and I unintentionally removed this block from PutMsg. Return it please where it was (just in that function), and try if that works better for you:

Code:

void PutMsg(MQHCONN hConn,
                  MQCHAR8 MsgFormat,
                  MQHOBJ hQName,
                  MQCHAR48 QName,
                  MQBYTE *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) );
   memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );

   MQPUT(hConn,             /* connection handle                */
         hQName,            /* object handle                    */
         &md,               /* message descriptor               */
         &pmo,              /* default options                  */
         UserMsgLen,        /* message length                   */
         (MQBYTE *)UserMsg, /* message buffer                   */
         &CompCode,         /* completion code                  */
         &Reason);          /* reason code                      */

   /* set CorrelId to MsgId of request */
   memcpy(md.CorrelId, md.MsgId, sizeof(md.CorrelId) );

   if (Reason != MQRC_NONE) {
      printf("MQPUT ended with with Reason Code %d and Comp Code %d\n",
                     Reason, CompCode);
   if (iqmReason != MQRC_ALREADY_CONNECTED)
    {
        MQDISC(&hConn,
        &iqmCompCode,
        &iqmReason);

        if (iqmReason != MQRC_NONE)
            printf("MQDISC ended with reason code %d\n", iqmReason);
    }
      exit( -1 );
   }
   printf("MQPUT Call Reason = %d, CC = %d\n",Reason,CompCode);
   printf("***********************************************************************\n");
}

void GetMsg(MQHCONN hConn, MQLONG MQParm, MQHOBJ hQName,
                  MQBYTE *UserMsg, MQLONG ReadBufferLen)
{
   MQLONG CompCode, Reason, msglen;

   gmo.Options      = MQParm;
   gmo.WaitInterval = 9000000;

   /* reset MsgId to get a new one  */
   memcpy(md.MsgId,    MQMI_NONE, sizeof(md.MsgId) );

   MQGET(hConn,             /* connection handle                */
         hQName,            /* object handle                    */
         &md,               /* message descriptor               */
         &gmo,              /* get message options              */
         ReadBufferLen,     /* Buffer length                    */
         (MQBYTE *)UserMsg, /* message buffer                   */
         &msglen,           /* message length                   */
         &CompCode,         /* completion code                  */
         &Reason);          /* reason code                      */

   if (Reason != MQRC_NONE) {
      printf("MQGET ended with Reason Code %d and Comp Code %d\n",
                     Reason, CompCode);
   if (iqmReason != MQRC_ALREADY_CONNECTED)
    {
        MQDISC(&hConn,
        &iqmCompCode,
        &iqmReason);

        if (iqmReason != MQRC_NONE)
            printf("MQDISC ended with reason code %d\n", iqmReason);
    }
      exit( -1 );
   }
   printf("MQGET Call Reason = %d, CC = %d\n",Reason,CompCode);
   printf("***********************************************************************\n");
}


Without setting MsgId to MQMI_NONE before MQPUT, qmgr doesn't generate a unique value on each MQPUT, so same value may be preserved on the same memory location that is reused by several program executions. That may cause you problems, especially if you rearange the code to do more than one put in application and don't ensure that you get the responses before putting new requests. I haven't experienced that although with that code that we were both testing.
Back to top
View user's profile Send private message Visit poster's website
jcv
PostPosted: Wed Apr 16, 2014 6:46 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

That code really worked OK even without that setting for me. Besides that, I think I'm gonna study a bit this initialization:

MQMD md = { MQMD_DEFAULT };

Since I believed MQMI_NONE is a default value for MsgId, but it obviously doesn't get initialized to that value in C, if you just use this line.
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Wed Apr 16, 2014 6:58 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There's a lot of blocks of code here, it's a long thread.

Somewhere, presumably, someone is setting the right MQGMO options to match the correlid?
Back to top
View user's profile Send private message
jcv
PostPosted: Wed Apr 16, 2014 7:21 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

According to this excerpt from cmqc.h:

Code:

 #define MQMD_DEFAULT {MQMD_STRUC_ID_ARRAY},\
                      MQMD_VERSION_1,\
                      MQRO_NONE,\
                      MQMT_DATAGRAM,\
                      MQEI_UNLIMITED,\
                      MQFB_NONE,\
                      MQENC_NATIVE,\
                      MQCCSI_Q_MGR,\
                      {MQFMT_NONE_ARRAY},\
                      MQPRI_PRIORITY_AS_Q_DEF,\
                      MQPER_PERSISTENCE_AS_Q_DEF,\
                      {MQMI_NONE_ARRAY},\
                      {MQCI_NONE_ARRAY},\
                      0,\
                      {""},\
                      {""},\
                      {""},\
                      {MQACT_NONE_ARRAY},\
                      {""},\
                      MQAT_NO_CONTEXT,\
                      {""},\
                      {""},\
                      {""},\
                      {""},\
                      {MQGI_NONE_ARRAY},\
                      1,\
                      0,\
                      MQMF_NONE,\
                      MQOL_UNDEFINED


md gets properly initialized even without adding that block that I removed. Even without that initialization, there is no way that code didn't work.
Back to top
View user's profile Send private message Visit poster's website
jcv
PostPosted: Thu Apr 17, 2014 5:22 am    Post subject: Reply with quote

Chevalier

Joined: 07 May 2007
Posts: 411
Location: Zagreb

mqjeff wrote:
Somewhere, presumably, someone is setting the right MQGMO options to match the correlid?


Obviously:

MQGMO gmo = { MQGMO_DEFAULT };

Excerpt from the same cmqc.h says that is exactly what is needed:

Code:

 #define MQGMO_DEFAULT {MQGMO_STRUC_ID_ARRAY},\
                       MQGMO_VERSION_1,\
                       (MQGMO_NO_WAIT+MQGMO_PROPERTIES_AS_Q_DEF),\
                       0,\
                       0,\
                       0,\
                       {""},\
                       (MQMO_MATCH_MSG_ID+MQMO_MATCH_CORREL_ID),\
                       MQGS_NOT_IN_GROUP,\
                       MQSS_NOT_A_SEGMENT,\
                       MQSEG_INHIBITED,\
                       ' ',\
                       {MQMTOK_NONE_ARRAY},\
                       MQRL_UNDEFINED,\
                       0,\
                       MQHM_NONE



However, Vignesh also copied from somewhere a line that stores MQCI_NONE to correlID before each get, instead of storing MsgId to it just once, after put.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next Page 6 of 7

MQSeries.net Forum Index » IBM MQ Security » MQRC 3014 on MQCMD_SET_AUTH_REC
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.