MQOPEN and clusters
The queue to which a message is put to, or read from, when a cluster queue is opened, depends on the MQOPEN call.
Selecting the target queue
If you do not provide a queue manager name in the object descriptor, MQOD
, the queue manager selects the queue manager to send the message to. If you do provide a queue manager name in the object descriptor, then messages are always sent to the queue manager you have selected.
If the queue manager is selecting the target queue manager, the selection depends on the binding options, MQOO_BIND_*
and if a local queue exists. If there is a local instance of the queue, it is always opened in preference to a remote instance, unless the CLWLUSEQ attribute is set to ANY
. Otherwise, the selection depends on the binding options. Either MQOO_BIND_ON_OPEN
or MQOO_BIND_ON_GROUP
must be specified when using message groups with clusters to ensure that all messages in the group are processed at the same destination.
If the queue manager is selecting the target queue manager, it does so in a round-robin fashion, using the workload management algorithm; see Workload balancing in clusters.
MQOO_BIND_ON_OPEN
- the algorithm is used once at the time the queue is opened by the application.MQOO_BIND_NOT_FIXED
- the algorithm is used for every message put to the queue.MQOO_BIND_ON_GROUP
- the algorithm is used once at the start of each message group.
MQOO_BIND_ON_OPEN
- The
MQOO_BIND_ON_OPEN
option on the MQOPEN call specifies that the target queue manager is to be fixed. Use theMQOO_BIND_ON_OPEN
option if there are multiple instances of the same queue within a cluster. All messages put to the queue specifying the object handle returned from the MQOPEN call are directed to the same queue manager.- Use the
MQOO_BIND_ON_OPEN
option if messages have affinities. For example, if a batch of messages is all to be processed by the same queue manager, specifyMQOO_BIND_ON_OPEN
when you open the queue. IBM® MQ fixes the queue manager and the route to be taken by all messages put to that queue. - If
MQOO_BIND_ON_OPEN
option is specified, the queue must be reopened for a new instance of the queue to be selected.
- Use the
MQOO_BIND_NOT_FIXED
- The
MQOO_BIND_NOT_FIXED
option on the MQOPEN call specifies that the target queue manager is not fixed. Messages written to the queue specifying the object handle returned from the MQOPEN call are routed to a queue manager at MQPUT time on a message-by-message basis. Use theMQOO_BIND_NOT_FIXED
option if you do not want to force all your messages to be written to the same destination.- Do not specify
MQOO_BIND_NOT_FIXED
andMQMF_SEGMENTATION_ALLOWED
at the same time. If you do, the segments of your message might be delivered to different queue managers, scattered throughout the cluster.
- Do not specify
MQOO_BIND_ON_GROUP
- Allows an application to request that a group of messages is allocated to the same destination instance. This option is valid only for queues, and affects only cluster queues. If specified for a queue that is not a cluster queue, the option is ignored.
- Groups are only routed to a single destination when MQPMO_LOGICAL_ORDER is specified on the MQPUT. When MQOO_BIND_ON_GROUP is specified, but a message is not part of a logical group, BIND_NOT_FIXED behavior is used instead.
MQOO_BIND_AS_Q_DEF
- If you do not specify either
MQOO_BIND_ON_OPEN
,MQOO_BIND_NOT_FIXED
orMQOO_BIND_ON_GROUP
, the default option isMQOO_BIND_AS_Q_DEF
. UsingMQOO_BIND_AS_Q_DEF
causes the binding that is used for the queue handle to be taken from the DefBind queue attribute.
Relevance of MQOPEN options
The MQOPEN options MQOO_BROWSE, MQOO_INPUT_*
, or MQOO_SET
require a local instance of the cluster queue for MQOPEN to succeed.
The MQOPEN options MQOO_OUTPUT
, MQOO_BIND_*
, or MQOO_INQUIRE
do not require a local instance of the cluster queue to succeed.