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 Java / JMS » Problems reading MQCFT_GROUP data in Command Event Queue

Post new topic  Reply to topic
 Problems reading MQCFT_GROUP data in Command Event Queue « View previous topic :: View next topic » 
Author Message
JKulcyk
PostPosted: Thu Sep 29, 2011 8:52 am    Post subject: Problems reading MQCFT_GROUP data in Command Event Queue Reply with quote

Novice

Joined: 24 Apr 2009
Posts: 16

I am trying to interpret data from event queues. I am able to process messages from the CONFIG, LOGGER, PERFM and QMGR Event queues, but am having troubles with the COMMAND queue.

The message from the command queue says it has two parameters. The first is a MQCFT_GROUP parm of type MQGACF_COMMAND_CONTEXT. It returns a getValue() of 9. This matches with the number of parameters the manual says are in the MQGACF_COMMAND_CONTEXT group (1). I am having problems figuring out how to access those group parameters. When I do a PCFParameter.nextParameter(Message) it skips over the group parameters and takes me to the next group parameter MQGACF_COMMAND_DATA. I did not think I could skip over the group elements (2).

Is anyone able to tell me where I am going wrong trying to read those group parameters? I would think I would be able to read them into another PCFParameter or MQCFGR structure. The main body of the code is below, if the full runnable code helps let me know and I can post that.

Thanks in advance,
-John


Code:

         while (queue.getCurrentDepth() > 0) {

            MQMessage Message = new MQMessage();
            MQGetMessageOptions gmo = new MQGetMessageOptions();
            queue.get(Message, gmo);
            int msgType1 = Message.messageType;
            MQCFH cfh = new MQCFH(Message);

            int msgType = cfh.getType();

            int msgLength = cfh.getStrucLength();
            int msgVersion = cfh.getVersion();
            String msgFormat = Message.format;
            int msgCommand = cfh.getCommand();
            int msgSeqNumber = cfh.getMsgSeqNumber();
            int msgControl = cfh.getControl();
            int msgCompCode = cfh.getCompCode();
            int msgReason = cfh.getReason();
            int msgParmCount = cfh.getParameterCount();

            System.out.format("Message format:    %s  %n", msgFormat);
            System.out.format("Message type:      %d  %d  %s  %n",
                  msgType1, msgType,
                  MQConstants.lookup(msgType, "MQCFT_.*"));
            System.out.format("Message command:   %s  %n",
                  MQConstants.lookup(msgCommand, "MQCMD_.*"));
            System.out.format("Message reason:    %s  %n",
                  MQConstants.lookupReasonCode(msgReason));
            System.out.format("Message length:    %d  %n", msgLength);
            System.out.format("Message version:   %d  %n", msgVersion);
            System.out.format("Message seq num:   %d  %n", msgSeqNumber);
            System.out.format("Message control:   %s  %n",
                  MQConstants.lookup(msgControl, "MQCFC_.*"));
            System.out.format("Message comp code: %s  %n",
                  MQConstants.lookup(msgCompCode, "MQCC_.*"));
            System.out.format("Message # parms:   %d  %n", msgParmCount);


            PCFParameter p;
            String parmString;


            for (int i = 0; i < cfh.getParameterCount(); i++) {
               p = PCFParameter.nextParameter(Message);
               int parmType = p.getType();
               
               int parmCode = p.getParameter();

               switch (parmType) {
               case MQConstants.MQCFT_STRING:
                  parmString = p.getStringValue();
                  break;
               case MQConstants.MQCFT_BYTE_STRING:
                  parmString = p.getStringValue();
                  break;
               case MQConstants.MQCFT_INTEGER:
                  parmString = ConstantXlate.intXlate(parmCode,
                        (Integer) p.getValue());
                  break;
               case MQConstants.MQCFT_INTEGER_LIST:
                  parmString = ConstantXlate.intListXlate(parmCode,
                        (int[]) p.getValue());
                  break;
               case MQConstants.MQCFT_STRING_LIST:
                  parmString = ConstantXlate.strListXlate(parmCode,
                        (String[]) p.getValue());
                  break;
                  
               case MQConstants.MQCFT_GROUP:
                                                 // NEED HELP HERE
                  parmString = "Working on it  " + p.getValue() + "  " + p.getParameterName();
                                    
                  break;

               default:
                  System.out.println("Paramater: " + p.getType() + "    "
                        + MQConstants.lookup(p.getType(), "MQCFT_.*"));
                  parmString = p.getStringValue();
               }


               System.out.println("");

            }

         }



(1) http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzax.doc%2Fmo11490_.htm
(2) Pg 24/26 http://www.gse-nordic.org/Working%20Groups/GNRC/Conferences/2005/WMQ%20Stream/s61
Back to top
View user's profile Send private message
markt
PostPosted: Thu Sep 29, 2011 11:37 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 504

Groups can be iterated through as well. This code fragment deals with events that are known to have a max of two layers of group. The original I cut and sanitised this from does work, even if this won't compile!

Code:

 while ((p = PCFParameter.nextParameter(msg)) != null) {

        if (p instanceof MQCFGR) {
          MQCFGR g = (MQCFGR) p;
          for (Enumeration e = g.getParameters(); e.hasMoreElements();) {
            p = (PCFParameter) e.nextElement();   
         
            // These messages only have 2 layers nested group, so we don't need to
            // get recursive. Other uses may need recursion
            if (p instanceof MQCFGR) {
              MQCFGR g2 = (MQCFGR) p;
              print p ...
              U.debug("Found embedded group " + g2.getParameterName());
              for (Enumeration e2 = g2.getParameters(); e2.hasMoreElements();) {
                PCFParameter p2 = (PCFParameter) e2.nextElement();
                pn = p2.getParameterName();
                U.debug("Reading parameter " + pn);
                print p2 ...
              } 
            } else {
              print p ...
            }
          }
        } else {
          print p...
        }
}
Back to top
View user's profile Send private message
JKulcyk
PostPosted: Wed Oct 05, 2011 6:07 am    Post subject: Problems reading MQCFT_GROUP data in Command Event Queue Reply with quote

Novice

Joined: 24 Apr 2009
Posts: 16

Markt - Thanks for the code snippet, it works great! Should we ever find ourselves in the same location, your beer is on me.

Still slogging through some details, but things are looking much better, thanks again.

-John
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Problems reading MQCFT_GROUP data in Command Event Queue
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.