As input to the MQOPEN call, you must supply:
The output from MQOPEN is:
The scope of an object handle (Hobj) is the same as the scope of a connection handle (Hconn). This is covered in Scope of MQCONN or MQCONNX and Shared (thread independent) connections with MQCONNX, however there are additional considerations in some environments:
Descriptions of the parameters of the MQOPEN call are given in WebSphere MQ Application Programming Reference.
The following sections describe the information you must supply as input to MQOPEN.
Use the MQOD structure to identify the object you want to open. This structure is an input parameter for the MQOPEN call. (The structure is modified by the queue manager when you use the MQOPEN call to create a dynamic queue.)
For full details of the MQOD structure see WebSphere MQ Application Programming Reference.
For information about using the MQOD structure for distribution lists, see Using the MQOD structure under Distribution lists.
When you open a WebSphere MQ queue, the MQOPEN call performs a name resolution function on the queue name you specify. This determines on which queue the queue manager performs subsequent operations. This means that when you specify the name of an alias queue or a remote queue in your object descriptor (MQOD), the call resolves the name either to a local queue or to a transmission queue. If a queue is opened for any type of input, browse, or set, it resolves to a local queue if there is one, and fails otherwise. It resolves to a nonlocal queue only if it is opened for output only, inquire only, or output and inquire only. See Table 3 for an overview of the name resolution process. Note that the name you supply in ObjectQMgrName is resolved before that in ObjectName.
Table 3 also shows how you can use a local definition of a remote queue to define an alias for the name of a queue manager. This allows you to select which transmission queue is used when you put messages on a remote queue, so you could, for example, use a single transmission queue for messages destined for many remote queue managers.
To use the following table, first read down the two left-hand columns, under the heading "Input to MQOD", and select the appropriate case. Then read across the corresponding row, following any instructions. Following the instructions in the "Resolved names" columns, you can either return to the "Input to MQOD" columns and insert values as directed, or you can exit the table with the results supplied. For example, you may be required to input ObjectName.
Table 3. Resolving queue names when using MQOPEN SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
SYSTEM.QSG. TRANSMIT.QUEUE (see note)
Input to MQOD
Resolved names
ObjectQMgrName
ObjectName
ObjectQMgrName
ObjectName
Transmission queue
Blank or local queue manager
Local queue with no CLUSTER attribute
Local queue manager
Input ObjectName
Not applicable (local queue used)
Blank queue manager
Local queue with CLUSTER attribute
Workload management selected cluster queue manager or specific cluster
queue manager selected on PUT
Input ObjectName
SYSTEM.CLUSTER. TRANSMIT.QUEUE and local queue used
Local queue manager
Local queue with CLUSTER attribute
Local queue manager
Input ObjectName
Not applicable (local queue used)
Blank or local queue manager
Model queue
Local queue manager
Generated name
Not applicable (local queue used)
Blank or local queue manager
Alias queue with or without CLUSTER attribute
Perform name resolution again with ObjectQMgrName
unchanged, and input ObjectName set to the
BaseQName in the alias queue definition object.
Must not resolve to an alias queue
Blank or local queue manager
Local definition of a remote queue with or without CLUSTER attribute
Perform name resolution again with ObjectQMgrName set
to RemoteQMgrName, and ObjectName set
to RemoteQName. Must not resolve remote queues
Name of XmitQName attribute, if non-blank;
otherwise RemoteQMgrName in the remote queue definition
object.
Blank queue manager
No matching local object; cluster queue found
Workload management selected cluster queue manager or specific cluster
queue manager selected on PUT
Input ObjectName
SYSTEM.CLUSTER. TRANSMIT.QUEUE
Blank or local queue manager
No matching local object; cluster queue not found
Error, queue not found
Not applicable
Name of a local transmission queue
(Not resolved)
Input ObjectQMgrName
Input ObjectName
Input ObjectQMgrName
Queue manager alias definition (RemoteQMgrName may be
the local queue manager)
(Not resolved, remote queue)
Perform name resolution again with ObjectQMgrName set
to RemoteQMgrName. Must not resolve to remote
queues
Input ObjectName
Name of XmitQName attribute, if non-blank;
otherwise RemoteQMgrName in the remote queue definition
object.
Queue manager is not the name of any local object; cluster queue
managers or queue manager alias found
(Not resolved)
ObjectQMgrName or specific cluster queue manager
selected on PUT
Input ObjectName
SYSTEM.CLUSTER. TRANSMIT.QUEUE
Queue manager is not the name of any local object; no cluster
objects found
(Not resolved)
Input ObjectQMgrName
Input ObjectName
DefXmitQName attribute of the queue manager where
DefXmitQName is supported.
Notes:
Opening an alias queue also opens the base queue to which the alias resolves, and opening a remote queue also opens the transmission queue. Therefore you cannot delete either the queue you specify or the queue to which it resolves while the other one is open.
The resolved queue name and the resolved queue manager name are stored in the ResolvedQName and ResolvedQMgrName fields in the MQOD.
For more information about name resolution in a distributed queuing environment see WebSphere MQ Intercommunication.
In the Options parameter of the MQOPEN call, you must choose one or more options to control the access you are given to the object you are opening. With these options you can:
To specify that all messages MQPUT to a queue are to be routed to the same queue manager by the same route use the MQOO_BIND_ON_OPEN option on the MQOPEN call. To specify that a destination is to be selected at MQPUT time, that is, on a message-by-message basis, use the MQOO_BIND_NOT_FIXED option on the MQOPEN call. If you specify neither of these options the default, MQOO_BIND_AS_Q_DEF, is used. In this case the binding used for the queue handle is taken from the DefBind queue attribute, which can take the value MQBND_BIND_ON_OPEN or MQBND_BIND_NOT_FIXED. If the queue you open is not a cluster queue the MQOO_BIND_* options are ignored. If you specify the name of the local queue manager in the MQOD the local instance of the cluster queue is selected. If the queue manager name is blank, any instance can be selected. See WebSphere MQ Queue Manager Clusters for more information.
To open a queue in order to put messages on it, use the MQOO_OUTPUT option.
To open a queue so that you can browse the messages on it, use the MQOPEN call with the MQOO_BROWSE option. This creates a browse cursor that the queue manager uses to identify the next message on the queue. For more information, see Browsing messages on a queue.
Notes:
There are three options that control the opening of a queue in order to remove messages from it. You can use only one of them in any MQOPEN call. These options define whether your program has exclusive or shared access to the queue. Exclusive access means that, until you close the queue, only you can remove messages from it. If another program attempts to open the queue to remove messages, its MQOPEN call fails. Shared access means that more than one program can remove messages from the queue.
The most advisable approach is to accept the type of access that was
intended for the queue when the queue was defined. The queue definition
involved the setting of the Shareability and the
DefInputOpenOption attributes. To accept this
access, use the MQOO_INPUT_AS_Q_DEF option. Refer to Table 4 to see how the setting of these attributes affects the type
of access you will be given when you use this option.
Table 4. How queue attributes and options of the MQOPEN call affect access to queues
Queue attributes | Type of access with MQOPEN options | |||
---|---|---|---|---|
Shareability | DefInputOpenOption | AS_Q_DEF | SHARED | EXCLUSIVE |
SHAREABLE | SHARED | shared | shared | exclusive |
SHAREABLE | EXCLUSIVE | exclusive | shared | exclusive |
NOT_SHAREABLE* | SHARED* | exclusive | exclusive | exclusive |
NOT_SHAREABLE | EXCLUSIVE | exclusive | exclusive | exclusive |
|
Alternatively:
Notes:
To open a queue so that you can set its attributes, use the MQOO_SET option. You cannot set the attributes of any other type of object (see Chapter 12, Inquiring about and setting object attributes).
To open an object so that you can inquire about its attributes, use the MQOO_INQUIRE option.
If you want to be able to associate context information with a message when you put it on a queue, you must use one of the message context options when you open the queue.
The options allow you to differentiate between context information that relates to the user who originated the message, and that which relates to the application that originated the message. Also, you can opt to set the context information when you put the message on the queue, or you can opt to have the context taken automatically from another queue handle.
For more information about the subject of message context, see Message context.
When you attempt to open an object using the MQOPEN call, the queue manager checks that you have the authority to open that object. If you are not authorized, the call fails.
However, server programs may want the queue manager to check the authorization of the user on whose behalf they are working, rather than the server's own authorization. To do this, they must use the MQOO_ALTERNATE_USER_AUTHORITY option of the MQOPEN call, and specify the alternate user ID in the AlternateUserId field of the MQOD structure. Typically, the server would get the user ID from the context information in the message it is processing.
In the CICS environment on z/OS, if you use the MQOPEN call when the queue manager is in a quiescing state, the call always fails. In other z/OS environments, OS/400, OS/2, Windows systems and in UNIX systems environments, the call fails when the queue manager is quiescing only if you use the MQOO_FAIL_IF_QUIESCING option of the MQOPEN call.