Accessing queues and processes

To access queues, use the MQQueueManager class. The MQOD (object descriptor structure) is collapsed into the parameters of these methods. For example, to open a queue on a queue manager represented by an MQQueueManager object called queueManager, use the following code:

MQQueue queue = queueManager.AccessQueue("qName",
                                         MQC.MQOO_OUTPUT,
                                         "qMgrName",
                                         "dynamicQName",
                                         "altUserId");

The options parameter is the same as the Options parameter in the MQOPEN call.

The AccessQueue method returns a new object of class MQQueue.

When you have finished using the queue, use the Close() method to close it, as in the following example:

queue.Close();

With WebSphere MQ .NET, you can also create a queue by using the MQQueue constructor. The parameters are exactly the same as for the accessQueue method, with the addition of a queue manager parameter specifying the instantiated MQQueueManager object to use. For example:

MQQueue queue = new MQQueue(queueManager,
                            "qName",
                            MQC.MQOO_OUTPUT,
                            "qMgrName",
                            "dynamicQName",
                            "altUserId");

Constructing a queue object in this way enables you to write your own subclasses of MQQueue.