1 reply Latest Post - ‏2013-01-30T10:53:19Z by SystemAdmin
10 Posts

Pinned topic Getting error in collection for Statistics of Queue using My Own Code

‏2013-01-30T09:45:33Z |
Hi All I am Trying to write a code to collect statistics information of Queue in IBM MQ .
Here Is an Overview of What I am trying to Do .

1: First Step I connected to queue manager by server channel SYSTEM.DEF.SVRCONN . I have provided (host,port,server channel) and created a queue-manager Instance . Connection was successful .
2: Now I tried to open Queue SYSTEM.ADMIN.STATISTICS.QUEUE (which contains all statistics properties ) with provided open options and queue_name
openOption = MQC.MQOO_INQUIRE + MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING; . Queue Opened successfully .
3: Now I tried to read this queue with MQGetMessageOptions as stated below
gmo.options = MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_NO_WAIT + MQC.MQGMO_CONVERT; . Now I get all messages in object MQMessage with these options using MQQueue.get(MQMessage,MQGetMessageOptions)
4: Now I tried to parse this message using PCFMessage like PCFMesasage(MQMessage) but this returned me exception MQJE001: Completion Code 2, Reason 3001 . 3001 is basically for MQRCCF_CFH_TYPE_ERROR .

Internal Information about PCFMessage Class for forth step .
PCFMessage constructor calls MQCFH class with MQCFH(MQMessage )
MQCFH class having a field type (type of structure) which is being matched with readInt value of MQMessage and throws exception (2,3001,MQmessage )

Code snippet given below .

public void initialize(MQMessage message)
throws MQException, IOException
this.type = message.readInt();

switch (this.type) {
case 1:
case 2:
case 7:
case 16:
case 17:
case 18:
case 19:
case 3:
case 4:
case 5:
case 6:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
System.out.println("*** type = " + this.type);
throw new MQException(2, 3001, message);

Here it tries to compare value readInt from 1 to 19 but value I am getting is 21 and hence throwing error .
I could not get why this comparison is done any what these values represent . Please help if I need to change my MQGetMessageOptions to get correct type .
Updated on 2013-01-30T10:53:19Z at 2013-01-30T10:53:19Z by SystemAdmin
  • SystemAdmin
    8523 Posts

    Re: Getting error in collection for Statistics of Queue using My Own Code

    ‏2013-01-30T10:53:19Z  in response to RaviMishra
    A quick check of the PCF constants in cmqcfc.h shows that MQCFT_STATISTICS has a value of 21. So all this is telling you is that you have a statistics message, which is no surprise since you got it off the SYSTEM.ADMIN.STATISTICS.QUEUE.

    Your switch statement only appears to look for:-
    case 1:  - MQCFT_COMMAND 
    case 2:  - MQCFT_RESPONSE 
    case 7:  - MQCFT_EVENT 
    case 16: - MQCFT_COMMAND_XR 
    case 17: - MQCFT_XR_MSG 
    case 18: - MQCFT_XR_ITEM 
    case 19: - MQCFT_XR_SUMMARY 
    case 3:  - MQCFT_INTEGER 
    case 4:  - MQCFT_STRING 
    case 5:  - MQCFT_INTEGER_LIST 
    case 6:  - MQCFT_STRING_LIST 
    case 8:  - MQCFT_USER 
    case 9:  - MQCFT_BYTE_STRING 
    case 10: - MQCFT_TRACE_ROUTE 
    case 11: 
    case 12: - MQCFT_REPORT 
    case 13: - MQCFT_INTEGER_FILTER 
    case 14: - MQCFT_STRING_FILTER 

    But you are missing these:-
    MQCFT_GROUP                    20 MQCFT_STATISTICS               21 MQCFT_ACCOUNTING               22 MQCFT_INTEGER64                23 MQCFT_INTEGER64_LIST           25 MQCFT_APP_ACTIVITY             26

    You should update your switch statement to include the other MQCFT values if you intend to use this code to parse Statistics messages.

    Alternatively, you could use the product supplied java classes for deconstructing PCF messages. See Handling PCF messages with WebSphere® MQ classes for Java