Options (MQLONG)

This provides options to control the action of the MQSUB call.

We must specify at least one of the following options:

  • MQSO_ALTER
  • MQSO_RESUME
  • MQSO_CREATE

To specify more than one option, either add the values together (do not add the same constant more than once), or combine the values using the bitwise OR operation (if the programming language supports bit operations).

Combinations that are not valid are noted in this topic; any other combinations are valid.

Access or creation options: Access and creation options control whether a subscription is created, or whether an existing subscription is returned or altered. We must specify at least one of these options.

Combination of options Notes
MQSO_CREATE Creates a subscription if one does not exist. This combination fails if the subscription exists.
MQSO_RESUME Resumes an existing subscription. This combination fails if no subscription exists.
MQSO_CREATE + MQSO_RESUME Creates a subscription if one does not exist and resumes a matching one, if it does exist. This combination is useful when it is used in an application that is run a number of times.
MQSO_ALTER (see note) Resumes an existing subscription, altering any fields to match that specified in the MQSD. This combination fails if no subscription exists.
MQSO_CREATE + MQSO_ALTER (see note) Creates a subscription if one does not exist and resumes a matching one, if it does exist, altering any fields to match that specified in the MQSD. This combination is useful combination when used in an application that wants to ensure that its subscription is in a certain state before proceeding.
Note:

Options specifying MQSO_ALTER can also specify MQSO_RESUME, but this combination has no additional effect to specifying MQSO_ALTER alone. MQSO_ALTER implies MQSO_RESUME, because calling MQSUB to alter a subscription implies that the subscription will also be resumed. The opposite is not true, however: resuming a subscription does not imply it is to be altered.

    MQSO_CREATE

    Create a new subscription for the topic specified. If a subscription using the same SubName exists, the call fails with MQRC_SUB_ALREADY_EXISTS. This failure can be avoided by combining the MQSO_CREATE option with MQSO_RESUME. The SubName is not always necessary. For more details, see the description of that field.

    Combining MQSO_CREATE with MQSO_RESUME returns a handle to a pre-existing subscription for the specified SubName if one is found; if there is no existing subscription, a new one is created using all the fields provided in the MQSD.

    MQSO_CREATE can also be combined with MQSO_ALTER to similar effect.

    MQSO_RESUME

    Return a handle to a pre-existing subscription which matches that specified by SubName. No changes are made to the matching subscriptions attributes and they are returned on output in the MQSD structure. Only the following MQSD fields are used: StrucId, Version, Options, AlternateUserId and AlternateSecurityId, and SubName.

    The call fails with reason code MQRC_NO_SUBSCRIPTION if a subscription does not exist matching the full subscription name. This failure can be avoided by combining the MQSO_CREATE option with MQSO_RESUME.

    The user ID of the subscription is the user ID that created the subscription, or if it has been later altered by a different user ID, it is the user ID of the most recent successful alteration. If an AlternateUserId is used, and use of alternate user IDs is allowed for that user, the alternate user ID is recorded as the user ID that created the subscription instead of the user ID under which the subscription was made.

    If a matching subscription exists that was created without the MQSO_ANY_USERID option, and the user ID of the subscription is different from that of the application requesting a handle to the subscription, the call fails with reason code MQRC_IDENTITY_MISMATCH.

    If a matching subscription exists and is currently in use, the call fails with MQRC_SUBSCRIPTION_IN_USE.

    If the subscription named in SubName is not a valid subscription to resume or alter from an application, the call fails with MQRC_INVALID_SUBSCRIPTION.

    MQSO_RESUME is implied by MQSO_ALTER so we do not need to combine it with that option. However, combining the two options does not cause an error.

    MQSO_ALTER

    Return a handle to a pre-existing subscription with the full subscription name matching that specified by the name in SubName. Any attributes of the subscription that are different from that specified in the MQSD are altered in the subscription unless alteration is disallowed for that attribute. Details are noted in the description of each attribute and are summarized in the following table. If you try to alter an attribute that cannot be changed, or to alter a subscription that has set the MQSO_IMMUTABLE option, the call fails with the reason code shown in the following table.

    The call fails with reason code MQRC_NO_SUBSCRIPTION if a subscription matching the full subscription name does not exist. We can avoid this failure by combining the MQSO_CREATE option with MQSO_ALTER.

    Combining MQSO_CREATE with MQSO_ALTER returns a handle to a pre-existing subscription for the specified SubName if one is found; if there is no existing subscription, a new one is created using all the fields provided in the MQSD.

    The user ID of the subscription is the user ID that created the subscription, or if it is later altered by a different user ID, it is the user ID of the most recent, successful alteration. If an AlternateUserId is used, and use of alternate user IDs is allowed for that user, then the alternate user ID is recorded as the user ID that created the subscription instead of the user ID under which the subscription was made.

    If a matching subscription exists that was created without the option MQSO_ANY_USERID and the user ID of the subscription is different from that of the application requesting a handle to the subscription, the call fails with reason code MQRC_IDENTITY_MISMATCH.

    If a matching subscription exists and is currently in use, the call fails with MQRC_SUBSCRIPTION_IN_USE.

    If the subscription named in SubName is not a valid subscription to resume or alter from an application, the call fails with MQRC_INVALID_SUBSCRIPTION.

The following table shows the ability of MQSO_ALTER to alter attribute values in MQSD and MQSUB.

Data type descriptor or function call Field name Can this attribute be altered using MQSO_ALTER Reason code
MQSD Durability options No MQRC_DURABILITY_NOT_ALTERABLE
MQSD Destination Options Yes None
MQSD Registration options Yes (see note 1) MQRC_GROUPING_NOT_ALTERABLE if you try to alter MQSO_GROUP_SUB
MQSD Publication options Yes (see note 2) None
MQSD Wildcard options No MQRC_TOPIC_NOT_ALTERABLE
MQSD Other options No (see note 3) None
MQSD ObjectName No MQRC_TOPIC_NOT_ALTERABLE
MQSD AlternateUserId No (see note 4) None
MQSD AlternateSecurityId No (see note 4) None
MQSD SubExpiry Yes None
MQSD ObjectString No MQRC_TOPIC_NOT_ALTERABLE
MQSD SubName No (see note 5 ) None
MQSD SubUserData Yes None
MQSD SubCorrelId Yes (see note 6) MQRC_GROUPING_NOT_ALTERABLE when in a grouped subscription
MQSD PubPriority Yes None
MQSD PubAccountingToken Yes None
MQSD PubApplIdentityData Yes None
MQSD SubLevel No MQRC_SUBLEVEL_NOT_ALTERABLE
MQSUB Hobj Yes (see note 6) MQRC_GROUPING_NOT_ALTERABLE when in a grouped subscription
Notes:
  1. MQSO_GROUP_SUB cannot be altered.
  2. MQSO_NEW_PUBLICATIONS_ONLY cannot be altered because it is not part of the subscription
  3. These options are not part of the subscription
  4. This attribute is not part of the subscription
  5. This attribute is the identity of the subscription being altered
  6. Alterable except when part of a grouped sub (MQSO_GROUP_SUB)

Durability options: The following options control how durable the subscription is. We can specify only one of these options. If we are altering an existing subscription using the MQSO_ALTER option, we cannot change the durability of the subscription. On return from an MQSUB call using MQSO_RESUME, the appropriate durability option is set.

    MQSO_DURABLE
    Request that the subscription to this topic remains until it is explicitly removed using MQCLOSE with the MQCO_REMOVE_SUB option. If this subscription is not explicitly removed it will remain even after this applications connection to the queue manager is closed.
    If a durable subscription is requested to a topic that is defined as not allowing durable subscriptions, the call fails with MQRC_DURABILITY_NOT_ALLOWED.

    MQSO_NON_DURABLE
    Request that the subscription to this topic is removed when the applications connection to the queue manager is closed, if it is not already explicitly removed. MQSO_NON_DURABLE is the opposite of the MQSO_DURABLE option, and is defined to aid program documentation. It is the default if neither is specified.

Destination options: The following option controls the destination that publications for a topic that has been subscribed to are sent to. If altering an existing subscription using the MQSO_ALTER option, the destination used for publications for the subscription can be changed. On return from an MQSUB call using MQSO_RESUME, this option is set if appropriate.

    MQSO_MANAGED

    Request that the destination that the publications are sent to is managed by the queue manager.

    The object handle returned in Hobj represents a queue manager managed queue and is for use with subsequent MQGET, MQCB, MQINQ, or MQCLOSE calls.

    An object handle returned from a previous MQSUB call cannot be provided in the Hobj parameter when MQSO_MANAGED is not specified.

    MQSO_NO_MULTICAST

    Request that the destination that the publications are sent to is not a multicast group address. This option is only valid when combined with the MQSO_MANAGED option. When a handle to a queue is provided in the Hobj parameter, multicast cannot be used for this subscription, and the option is not valid.

    If the topic is defined to only allow multicast subscriptions, using the MCAST(ONLY) setting, then the call fails with reason code MQRC_MULTICAST_REQUIRED.

Scope Option: The following option controls the scope of the subscription being made. If altering an existing subscription using the MQSO_ALTER option, this subscription scope option cannot be changed. On returning from an MQSUB call using MQSO-RESUME, the appropriate scope option is set.

    MQSO_SCOPE_QMGR
    This subscription is made only on the local queue manager. No proxy subscription is distributed to other queue managers in the network. Only publications that are published at this queue manager are sent to this subscriber. This overrides any behavior set using the SUBSCOPE topic attribute. Note: If not set, the subscription scope is determined by the SUBSCOPE topic attribute.

Registration options: The following options control the details of the registration that is made to the queue manager for this subscription. If altering an existing subscription using the MQSO_ALTER option, these registration options can be changed. On return from an MQSUB call using MQSO_RESUME the appropriate registration options is set.

    MQSO_GROUP_SUB

    This subscription is to be grouped with other subscriptions of the same SubLevel using the same queue and specifying the same correlation ID so that any publications to topics that would cause more than one publication message to be provided to the group of subscriptions, due to an overlapping set of topic strings being used, only causes one message to be delivered to the queue. If this option is not used, then each unique subscription (identified by SubName) that matches is provided with a copy of the publication which could mean more than one copy of the publication may be placed on the queue shared by a number of subscriptions.

    Only the most significant subscription in the group is provided with a copy of the publication. The most significant subscription is based on the Full topic name up to the point where a wildcard is found. If a mixture of wildcard schemes is used within the group, only the position of the wildcard is important. You are advised not to combine different wildcard schemes within a group of subscriptions that share the same queue.

    When creating a new grouped subscription it must still have a unique SubName, but if it matches the full topic name of an existing subscription in the group, the call fails with MQRC_DUPLICATE_GROUP_SUB.

    If the most significant subscription in group also specifies MQSO_NOT_OWN_PUBS and this is a publication from the same application, then no publication is delivered to the queue.

    When altering a subscription made with this option, the fields which imply the grouping, Hobj on the MQSUB call (representing the queue and queue manager name), and the SubCorrelId cannot be changed. Attempting to alter them causes the call to fail with MQRC_GROUPING_NOT_ALTERABLE.

    This option must be combined with MQSO_SET_CORREL_ID with a SubCorrelId that is not set to MQCI_NONE, and cannot be combined with MQSO_MANAGED.

    MQSO_ANY_USERID

    When MQSO_ANY_USERID is specified, the identity of the subscriber is not restricted to a single user ID. This allows any user to alter or resume the subscription when they have suitable authority. Only a single user may have the subscription at any one time. An attempt to resume use of a subscription currently in use by another application causes the call to fail with MQRC_SUBSCRIPTION_IN_USE.

    To add this option to an existing subscription the MQSUB call (using MQSO_ALTER) must come from the same user ID as the original subscription itself.

    If an MQSUB call refers to an existing subscription with MQSO_ANY_USERID set, and the user ID differs from the original subscription, the call succeeds only if the new user ID has authority to subscribe to the topic. On successful completion, future publications to this subscriber are put to the subscribers queue with the new user ID set in the publication message.

    Do not specify both MQSO_ANY_USERID and MQSO_FIXED_USERID. If neither is specified, the default is MQSO_FIXED_USERID.

    MQSO_FIXED_USERID

    When MQSO_FIXED_USERID is specified, the subscription can be altered or resumed by only the last user ID to alter the subscription. If the subscription has not been altered, it is the user ID that created the subscription.

    If an MQSUB verb refers to an existing subscription with MQSO_ANY_USERID set and alters the subscription using MQSO_ALTER to use option MQSO_FIXED_USERID, the user ID of the subscription is now fixed at this new user ID. The call succeeds only if the new user ID has authority to subscribe to the topic.

    If a user ID other than the one recorded as owning a subscription tries to resume or alter an MQSO_FIXED_USERID subscription, the call fails with MQRC_IDENTITY_MISMATCH. The owning user ID of a subscription can be viewed using the DISPLAY SBSTATUS command.

    Do not specify both MQSO_ANY_USERID and MQSO_FIXED_USERID. If neither is specified, the default is MQSO_FIXED_USERID.

Publication options: The following options control the way publications are sent to this subscriber. If altering an existing subscription using the MQSO_ALTER option, these publication options can be changed.

    MQSO_NOT_OWN_PUBS
    Tells the broker that the application does not want to see any of its own publications. Publications are considered to originate from the same application if the connection handles are the same. On return from an MQSUB call using MQSO_RESUME, this option is set if appropriate.

    MQSO_NEW_PUBLICATIONS_ONLY
    No currently retained publications are to be sent, when this subscription is created, only new publications. This option only applies when MQSO_CREATE is specified. Any subsequent changes to a subscription do not alter the flow of publications and so any publications retained on a topic, will have already been sent to the subscriber as new publications.
    If this option is specified without MQSO_CREATE the call fails with MQRC_OPTIONS_ERROR. On return from an MQSUB call using MQSO_RESUME, this option is not set even if the subscription was created using this option.
    If this option is not used, previously retained messages are sent to the destination queue provided. If this action fails due to an error, either MQRC_RETAINED_MSG_Q_ERROR or MQRC_RETAINED_NOT_DELIVERED, the creation of the subscription fails.

    MQSO_PUBLICATIONS_ON_REQUEST
    Set this option indicates that the subscriber will request information specifically when required. The queue manager does not send unsolicited messages to the subscriber. The retained publication (or possibly multiple publications if a wildcard is specified in the topic) is sent to the subscriber each time an MQSUBRQ call is made using the Hsub handle from a previous MQSUB call. No publications are sent as a result of the MQSUB call using this option. On return from an MQSUB call using MQSO_RESUME, this option is set if appropriate.
    This option is not valid in combination with a SubLevel greater than 1.

Read ahead options: The following options control whether non-persistent messages are sent to an application ahead of the application requesting them.

    MQSO_READ_AHEAD_AS_Q_DEF
    If the MQSUB call uses a managed handle, the default read ahead attribute of the model queue associated with the topic subscribed to determines whether messages are sent to the application before the application requests them.
    This is the default value.

    MQSO_NO_READ_AHEAD
    If the MQSUB call uses a managed handle, messages are not sent to the application before the application requests them.

    MQSO_READ_AHEAD
    If the MQSUB call uses a managed handle, messages might be sent to the application before the application requests them.

Note:

The following notes apply to the read ahead options:

  1. Only one of these options can be specified. If both MQOO_READ_AHEAD and MQOO_NO_READ_AHEAD are specified, reason code MQRC_OPTIONS_ERROR is returned. These options are only applicable if MQSO_MANAGED is specified.
  2. They are not applicable for MQSUB when a queue is passed which has been opened previously. Read ahead might not be enabled when requested. The MQGET options used on the first MQGET call might prevent read ahead from being enabled. Also, read ahead is disabled when the client is connecting to a queue manager where read ahead is not supported. If the application is not running as an IBM MQ client, these options are ignored.

Wildcard options: The following options control how wildcards are interpreted in the string provided in the ObjectString field of the MQSD. We can specify only one of these options. If altering an existing subscription using the MQSO_ALTER option, these wildcard options cannot be changed. On return from an MQSUB call using MQSO_RESUME, the appropriate wildcard option is set.

    MQSO_WILDCARD_CHAR
    Wildcards only operate on characters within the topic string.
    The behavior defined by MQSO_WILDCARD_CHAR is shown in the following table.

    Special Character Behavior
    Forward slash (/) No significance, just another character
    Asterisk (*) Wildcard, zero or more characters
    Question mark (?) Wildcard, 1 character
    Percent sign (%) Escape character to allow the characters (*), (?) or (%) to be used in a string and not be interpreted as a special character, for example, (%*), (%?) or (%%).
    For example, publishing on the following topic:
    /level0/level1/level2/level3/level4
    
    matches subscribers using the following topics:
    *
    /*
    / level0/level1/level2/level3/*
    / level0/level1/*/level3/level4
    / level0/level1/le?el2/level3/level4
    
    Note: This use of wildcards supplies exactly the meaning provided in IBM MQ V6 and WebSphere MB V6 when using MQRFH1 formatted messages for publish/subscribe. It is recommended that this is not used for newly written applications and is only used for applications that were previously running against that version and have not been changed to use the default wildcard behavior as described in MQSO_WILDCARD_TOPIC.

    MQSO_WILDCARD_TOPIC

    Wildcards only operate on topic elements within the topic string. This is the default behavior if none is chosen.

    The behavior required by MQSO_WILDCARD_TOPIC is shown in the following table:

    Special Character Behavior
    (/) Topic level separator
    Number sign (#) Wildcard: multiple topic level
    Plus sign (+) Wildcard: single topic level
    Notes: The (+) and (#) are not treated as wildcards if they are mixed in with other characters (including themselves) within a topic level. In the following string, the (#) and (+) characters are treated as ordinary characters.
    level0/level1/#+/level3/level#
    
    For example, publishing on the following topic:
    /level0/level1/level2/level3/level4
    
    matches subscribers using the following topics:
    #
    /#
    / level0/level1/level2/level3/#
    / level0/level1/+/level3/level4
    

Other options: The following options control the way the API call is issued rather than the subscription. On return from an MQSUB call using MQSO_RESUME, these options are unchanged. See AlternateUserId (MQCHAR12) for more details.

    MQSO_ALTERNATE_USER_AUTHORITY

    The AlternateUserId field contains a user identifier to use to validate this MQSUB call. The call can succeed only if this AlternateUserId is authorized to open the object with the specified access options, regardless of whether the user identifier under which the application is running is authorized to do so.

    MQSO_SET_CORREL_ID

    The subscription is to use the correlation identifier supplied in the SubCorrelId field. If this option is not specified, a correlation identifier is automatically created by the queue manager at subscription time and is returned to the application in the SubCorrelId field. For more information, see SubCorrelId (MQBYTE24) for more information.

    This option cannot be combined with MQSO_MANAGED.

    MQSO_SET_IDENTITY_CONTEXT

    The subscription is to use the accounting token and application identity data supplied in the PubAccountingToken and PubApplIdentityData fields.

    If this option is specified, the same authorization check is carried out as if the destination queue was accessed using an MQOPEN call with MQOO_SET_IDENTITY_CONTEXT, except in the case where the MQSO_MANAGED option is also used in which case there is no authorization check on the destination queue.

    If this option is not specified, the publications sent to this subscriber have default context information associated with them as follows:

    Field in MQMD Value used
    UserIdentifier The user ID associated with the subscription at the time the subscription was made.
    AccountingToken Determined from the environment if possible; Set to MQACT_NONE if not.
    ApplIdentityData Set to blanks

    This option is only valid with MQSO_CREATE and MQSO_ALTER. If used with MQSO_RESUME, the PubAccountingToken and PubApplIdentityData fields are ignored, so this option has no effect.

    If a subscription is altered without using this option where previously the subscription supplied identity context information, default context information is generated for the altered subscription.

    If a subscription allowing different user IDs to use it with option MQSO_ANY_USERID, is resumed by a different user ID, default identity context is generated for the new user ID now owning the subscription and any subsequent publications are delivered containing the new identity context.

    MQSO_FAIL_IF_QUIESCING

    The MQSUB call fails if the queue manager is in quiescing state. On z/OS, for a CICS or IMS application, this option also forces the MQSUB call to fail if the connection is in quiescing state.

Parent topic: Fields for MQSD