Rafi
Rafi

Reputation: 11

Finding XMIT Queue Depth using WebSphere MQ Classes for .Net

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.

Upvotes: 1

Views: 751

Answers (1)

Shashi
Shashi

Reputation: 15273

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();
        }
    }

Upvotes: 1

Related Questions