Daniel Nelson
Daniel Nelson

Reputation: 2338

Unable to get all queue names for your WebSphare MQ environment using IBM .Net API

How do you get all available queue names from client side, of your MQ environment using the IBM MQ lib for .Net (IBM.WMQ), Version 8.0? I have written a fine .Net application for reading and sending data to MQ (similar founds at code project).

Do anyone know if it is possible/how to get all available queue names from the IBM.WMQ .NET lib dynamically as you do when using tool IBM test tool RfhUtil.exe or as you can do with runmqsc DISPLAY QUEUE command from IBM .Net lib?

I have tried to brows the API, Reference manual and IBM programming guide without success.

Upvotes: 0

Views: 1516

Answers (2)

Shashi
Shashi

Reputation: 15273

There is certain level of PCF support in MQ .NET but it is undocumented. Here is a sample code to display queue names in queue manager.

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IBM.WMQ;
using IBM.WMQ.PCF;

namespace PCFNET
{
    class Program
    {
        static void Main(string[] args)
        {
            InquireQueue();
        }

    /// <summary>
    /// Display list of queue names and queue depth for each queue
    /// </summary>
    public static void InquireQueue()
    {
        PCFMessageAgent messageAgent = null;
        try
        {
            // Create bindings connection to queue manager
            messageAgent = new PCFMessageAgent("DEMOQMGR");

            // Build Inquire command to query queue name
            PCFMessage reqeuestMessage = new PCFMessage(MQC.MQCMD_INQUIRE_Q);
            reqeuestMessage.AddParameter(MQC.MQCA_Q_NAME, "*");

            // 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++)
            {
                try
                {
                    String qName = pcfResponse[pcfResponseIdx].GetStringParameterValue(MQC.MQCA_Q_NAME);
                    int qDepth = pcfResponse[pcfResponseIdx].GetIntParameterValue(MQC.MQIA_CURRENT_Q_DEPTH);
                    Console.WriteLine("QName: " + qName + "  Depth: " + qDepth);
                }
                catch (PCFException pcfex)
                {
                    //Ignore exception and get the next response
                }
            }
        }
        catch (PCFException pcfEx)
        {
            Console.Write(pcfEx);
        }
        catch (MQException ex)
        {
            Console.Write(ex);
        }
        catch (Exception ex)
        {
            Console.Write(ex);
        }
        finally
        {
            if (messageAgent != null)
                messageAgent.Disconnect();
        }
    }
}

}

Upvotes: 2

Stavr00
Stavr00

Reputation: 3314

There are PCFMessageAgent classes in Java, and I can see some seem to refer to equivalent classes in the .NET API.

It's possible to construct the PCF message yourself, as long as you have rights to access SYSTEM.ADMIN.COMMAND.QUEUE.

You also need to create reply queues dynamically based on SYSTEM.COMMAND.REPLY.MODEL or SYSTEM.MQSC.REPLY.QUEUE.

Upvotes: 0

Related Questions