Finding XMIT Queue Depth using WebSphere MQ Classes for .Net

妖精的绣舞 提交于 2020-01-02 20:27:41

问题


I want to get the Queue Depth for a Transmission Queue (XMIT queue) using WebSphere MQ Classes for .Net , can someone kindly help me giving a specific link/Pseudocode or .Net Classes/API to identify the XMIT queue depth. I have gone through the .Net API but didn't find any info on XMIT queue.


回答1:


You can use the MQ .NET PCF interface to query queue attributes. Below is the sample code snippet.

Note: MQ .NET PCF interface is undocumented interface and may not be supported. You will need to consult IBM.

    public static void InquireQueue()
    {
        PCFMessageAgent messageAgent = null;
        try
        {
            // Create connection to queue manager
            messageAgent = new PCFMessageAgent("QM3");

            // Build Inquire command to query attributes a queue
            PCFMessage pcfMsg = new PCFMessage(MQC.MQCMD_INQUIRE_Q);
            pcfMsg.AddParameter(MQC.MQCA_Q_NAME, "TO.QM2");

            // Send request and receive response
            PCFMessage[] pcfResponse = messageAgent.Send(pcfMsg);

            // 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_CURRENT_Q_DEPTH) 
                        Console.WriteLine("Queue Depth" + " - " + pm.GetValue());
                }
            }
        }
        catch (PCFException pcfEx)
        {
            Console.Write(pcfEx);
        }
        catch (MQException ex)
        {
            Console.Write(ex);
        }
        finally
        {
            if (messageAgent != null)
                messageAgent.Disconnect();
        }
    }


来源:https://stackoverflow.com/questions/24380641/finding-xmit-queue-depth-using-websphere-mq-classes-for-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!