Chapter 8. Opening and closing objects

To perform any of the following operations, you must first open the relevant WebSphere MQ object:

Use the MQOPEN call to open the object, using the options of the call to specify what you want to do with the object. The only exception is if you want to put a single message on a queue, then close the queue immediately. In this case, you can bypass the "opening" stage by using the MQPUT1 call (see Putting one message on a queue using the MQPUT1 call).

Before you open an object using the MQOPEN call, you must connect your program to a queue manager. This is explained in detail, for all environments, in Chapter 7, Connecting and disconnecting a queue manager.

There are four types of WebSphere MQ object that can be opened:

You open all of these objects in a similar way using the MQOPEN call. For more information about WebSphere MQ objects, see Chapter 4, WebSphere MQ objects.

You can open the same object more than once, and each time you get a new object handle. You might want to browse messages on a queue using one handle, and remove messages from the same queue using another handle. This saves using up resources to close and reopen the same object. You can also open a queue for browsing and removing messages at the same time.

Moreover, you can open multiple objects with a single MQOPEN and close them using MQCLOSE. See Distribution lists for information about how to do this.

When you attempt to open an object, the queue manager checks that you are authorized to open that object for the options you specify in the MQOPEN call.

Objects are closed automatically when a program disconnects from the queue manager. In the IMS environment, disconnection is forced when a program starts processing for a new user following a GU (get unique) IMS call. On the iSeries platform, objects are closed automatically when a job ends.

It is good programming practice to close objects you have opened. Use the MQCLOSE call to do this.

This chapter introduces opening and closing WebSphere MQ objects, under these headings:



© IBM Corporation 1993, 2002. All Rights Reserved