Search code examples
c#ibm-mqpcf

MQCMD_INQUIRE_Q_STATUS, PCF command returns "Unknown type" exception


I'm using the following code for returning handles of a queue, if the queue does not have any handle (open input/output count would be 0) it return MQRCCF_Q_STATUS_NOT_FOUND but when it has some open handle, it returns "Unknown type" exception.

    public void getQueue(string Name)
    {
            PCFMessage reqeuestMessage = new PCFMessage(MQC.MQCMD_INQUIRE_Q_STATUS);
            reqeuestMessage.AddParameter(MQC.MQCA_Q_NAME, Name);
            reqeuestMessage.AddParameter(CMQCFC.MQIACF_Q_STATUS_TYPE, CMQCFC.MQIACF_Q_HANDLE);
            PCFMessage[] response = agent.Send(reqeuestMessage);
            foreach (PCFMessage st in response)
            {
                ...
            }
    }

Solution

  • MQ PCF support in C# is limited , so it may not support some parameters. It's possible that the parameter that you are trying to inquire is not in the list of supported parameters. Please note MQ PCF in .NET is not officially supported by IBM MQ.

    If your intention is to inquire the number of applications have opened a queue for input & output, you can use the INQUIRE_Q command and filter out input/output count. Sample snippet is here:

                PCFMessage reqeuestMessage = new PCFMessage(MQC.MQCMD_INQUIRE_Q);
                reqeuestMessage.AddParameter(MQC.MQCA_Q_NAME, "Q1");
    
                // Send request and receive response
                PCFMessage[] pcfResponse = messageAgent.Send(reqeuestMessage);
    
                // Process and print response.
                int pcfResponseLen = pcfResponse.Length;
                for (int pcfResponseIdx = 0; pcfResponseIdx < pcfResponseLen; pcfResponseIdx++)
                {
                    PCFParameter[] parameters = pcfResponse[pcfResponseIdx].GetParameters();
                    foreach (PCFParameter pm in parameters)
                    {
                        // We just want to print current queue depth only
                        if ((pm.Parameter == MQC.MQIA_OPEN_OUTPUT_COUNT) || (pm.Parameter == MQC.MQIA_OPEN_INPUT_COUNT))
                            Console.WriteLine("Parameter: " + pm.Parameter + " - Value: " + pm.GetValue());
                    }
                }
    

    Hope this helped