DEFINE SUB

Use DEFINE SUB to allow an existing application to participate in a publish/subscribe application by allowing the administrative creation of a durable subscription.

Using MQSC commands

For information on how you use MQSC commands, see Performing local administration tasks using MQSC commands.

You can issue this command from sources CR. For an explanation of the source symbols, see Using commands on z/OS®.

Synonym: DEF SUB

Values shown above the main line in the railroad diagram are the defaults supplied with IBM® MQ, but your installation might have changed them. See Syntax diagrams.

DEFINE SUB

Read syntax diagramSkip visual syntax diagram DEFINE SUB ( string ) CMDSCOPE(' ')CMDSCOPE(qmgr-name)1CMDSCOPE(*)12DEST(string)DESTCLAS(PROVIDED)DESTCLAS(MANAGED)DESTCORL(string)DESTQMGR(string)EXPIRY(UNLIMITED)EXPIRY(integer)PSPROP(MSGPROP)PSPROP(COMPATNONERFH2)PUBACCT(string)PUBAPPID(string)PUBPRTY(ASPUB)PUBPRTY(ASQDEFinteger)NOREPLACEREPLACEREQONLY(NO)REQONLY(YES)SELECTOR(string)SUBLEVEL(1)SUBLEVEL(integer)SUBSCOPE(ALL)SUBSCOPE(QMGR)SUBUSER(string) TOPICOBJ ( string )3 TOPICSTR ( string )3 USERDATA(string)VARUSER(ANY)VARUSER(FIXED)WSCHEMA(TOPIC)WSCHEMA(CHAR)
Notes:
  • 1 Valid only on z/OS when the queue manager is a member of a queue-sharing group.
  • 2 Valid only on z/OS.
  • 3 At least one of TOPICSTR and TOPICOBJ must be present on DEFINE.

Usage notes for DEFINE SUB

  • You must provide the following information when you define a subscription:
    • The SUBNAME
    • A destination for messages
    • The topic to which the subscription applies
  • You can provide the topic name in the following ways:
    TOPICSTR
    The topic is fully specified as the TOPICSTR attribute.
    TOPICOBJ
    The topic is obtained from the TOPICSTR attribute of the named topic object. The named topic object is retained as the TOPICOBJ attribute of the new subscription. This method is provided to help you enter long topic strings through an object definition.
    TOPICSTR and TOPICOBJ
    The topic is obtained by the concatenation of the TOPICSTR attribute of the named topic object and the value of TOPICSTR (see the MQSUB API specification for concatenation rules). The named topic object is retained as the TOPICOBJ attribute of the new subscription.
  • If you specify TOPICOBJ, the parameter must name an IBM MQ topic object. The existence of the named topic object is checked at the time the command processes.
  • You can explicitly specify the destination for messages through the use of the DEST and DESTQMGR keywords.

    You must provide the DEST keyword for the default option of DESTCLAS(PROVIDED); if you specify DESTCLAS(MANAGED), a managed destination is created on the local queue manager, so you cannot specify either the DEST or DESTQMGR attribute. For more information, see Managed queues and publish/subscribe.

  • [z/OS]On z/OS only, at the time the DEF SUB command processes, no check is performed that the named DEST or DESTQMGR exists.

    These names are used at publishing time as the ObjectName and ObjectQMgrName for an MQOPEN call. These names are resolved according to the IBM MQ name resolution rules.

  • When a subscription is defined administratively using MQSC or PCF commands, the selector is not validated for invalid syntax. The DEFINE SUB command has no equivalent to the MQRC_SELECTION_NOT_AVAILABLE reason code that can be returned by the MQSUB API call.
  • TOPICOBJ, TOPICSTR, WSCHEMA, SELECTOR, SUBSCOPE, and DESTCLAS cannot be changed with DEFINE REPLACE.
  • When a publication has been retained, it is no longer available to subscribers at higher levels because it is republished at PubLevel 1.
  • Successful completion of the command does not mean that the action completed. To check for true completion, see the DEFINE SUB step in Checking that async commands for distributed networks have finished.

Parameter descriptions for DEFINE SUB

(string)
A mandatory parameter. Specifies the unique name for this subscription, see SUBNAME property.
[z/OS]CMDSCOPE
[z/OS] This parameter applies to z/OS only and specifies how the command runs when the queue manager is a member of a queue sharing group.
' '
The command runs on the queue manager on which it was entered. This is the default value.
qmgr-name
The command runs on the queue manager you specify, providing the queue manager is active within the queue sharing group.

You can specify a queue manager name, other than the queue manager on which the command was entered, only if you are using a queue sharing group environment and if the command server is enabled.

*
The command runs on the local queue manager and is also passed to every active queue manager in the queue sharing group. The effect of setting this value is the same as entering the command on every queue manager in the queue sharing group.

You cannot use CMDSCOPE as a filter keyword.

DEST(string)
The destination for messages published to this subscription; this parameter is the name of a queue.
DESTCLAS
System managed destination.
PROVIDED
The destination is a queue.
MANAGED
The destination is managed.
DESTCORL(string)
The CorrelId used for messages published to this subscription.

A blank value (default) results in a system generated correlation identifier being used.

If set to ' 000000000000000000000000000000000000000000000000 ' (48 zeros) the CorrelId set by the publishing application will be maintained in the copy of the message delivered to the subscription, unless messages are propagated across a publish/subscribe hierarchy.

Note: It is not possible to set the DESTCORL property programmatically with JMS.
DESTQMGR(string)
The destination queue manager for messages published to this subscription. You must define the channels to the remote queue manager, for example, the XMITQ, and a sender channel. If you do not, messages do not arrive at the destination.
EXPIRY
The time to expiry of the subscription object from the creation date and time.
(integer)
The time to expiry, in tenths of a second, from the creation date and time.
UNLIMITED
There is no expiry time. This is the default option supplied with the product.
LIKE(subscription-name)

The name of a subscription, the parameters of which are used as a model for this definition.

This parameter applies only to the DEFINE SUB command.

If this field is not supplied, and you do not complete the parameter fields related to the command, the values are taken from the default definition for subscriptions on this queue manager. Not completing this parameter is equivalent to specifying:

LIKE (SYSTEM.DEFAULT.SUB)
PSPROP
The manner in which publish subscribe related message properties are added to messages sent to this subscription.
NONE
Do not add publish subscribe properties to the message.
COMPAT
Publish/subscribe properties are added within an MQRFH version 1 header unless the message was published in PCF format.
MSGPROP
Publish/subscribe properties are added as message properties.
RFH2
Publish/subscribe properties are added within an MQRFH version 2 header.
PUBACCT(string)
Accounting token passed by the subscriber, for propagation into messages published to this subscription in the AccountingToken field of the MQMD.
PUBAPPID(string)
Identity data passed by the subscriber, for propagation into messages published to this subscription in the ApplIdentityData field of the MQMD.
PUBPRTY
The priority of the message sent to this subscription.
ASPUB
Priority of the message sent to this subscription is taken from the priority supplied in the published message.
ASQDEF
Priority of the message sent to this subscription is taken from the default priority of the queue defined as a destination.
(integer)
An integer providing an explicit priority for messages published to this subscription.
REPLACE and NOREPLACE
This parameter controls whether any existing definition is to be replaced with this one.
REPLACE
The definition replaces any existing definition of the same name. If a definition does not exist, one is created.

You cannot change TOPICOBJ, TOPICSTR, WSCHEMA, SELECTOR, SUBSCOPE, or DESTCLAS with DEFINE REPLACE.

NOREPLACE
The definition does not replace any existing definition of the same name.
REQONLY
Indicates whether the subscriber polls for updates using the MQSUBRQ API call, or whether all publications are delivered to this subscription.
NO
All publications on the topic are delivered to this subscription. This is the default value.
YES
Publications are only delivered to this subscription in response to an MQSUBRQ API call.
This parameter is equivalent to the subscribe option MQSO_PUBLICATIONS_ON_REQUEST.
SELECTOR(string)
A selector that is applied to messages published to the topic.
SUBLEVEL(integer)
The level within the subscription hierarchy at which this subscription is made. The range is zero through 9.
SUBSCOPE
Determines whether this subscription is forwarded to other queue managers, so that the subscriber receives messages published at those other queue managers.
ALL
The subscription is forwarded to all queue managers directly connected through a publish/subscribe collective or hierarchy.
QMGR
The subscription forwards messages published on the topic only within this queue manager.
Note: Individual subscribers can only restrict SUBSCOPE. If the parameter is set to ALL at topic level, then an individual subscriber can restrict it to QMGR for this subscription. However, if the parameter is set to QMGR at topic level, then setting an individual subscriber to ALL has no effect.
SUBNAME
The application's unique subscription name that is associated with the handle. This parameter is relevant only for handles of subscriptions to topics. It is not returned for other handles. Not all subscriptions will have a subscription name.
SUBUSER(string)
Specifies the user ID that is used for security checks that are performed to ensure that publications can be put to the destination queue associated with the subscription. This ID is either the user ID associated with the creator of the subscription or, if subscription takeover is permitted, the user ID that last took over the subscription. The length of this parameter must not exceed 12 characters.
TOPICOBJ(string)
The name of a topic object used by this subscription.
TOPICSTR(string)
Specifies a fully qualified topic name, or a topic set using wildcard characters for the subscription.
USERDATA(string)
Specifies the user data associated with the subscription. The string is a variable length value that can be retrieved by the application on an MQSUB API call and passed in a message sent to this subscription as a message property. The USERDATA is stored in the RFH2 header in the mqps folder with the key Sud.
[V9.0.0.2 Sep 2017][V9.0.2 Mar 2017]An IBM MQ classes for JMS application can retrieve the subscription user data from the message by using the constant JMS_IBM_SUBSCRIPTION_USER_DATA. For more information, see Retrieval of user subscription data.
VARUSER
Specifies whether a user other than the subscription creator can connect to and take over ownership of the subscription.
ANY
Any user can connect to and takeover ownership of the subscription.
FIXED
Takeover by another USERID is not permitted.
WSCHEMA
The schema to be used when interpreting any wildcard characters in the topic string.
CHAR
Wildcard characters represent portions of strings.
TOPIC
Wildcard characters represent portions of the topic hierarchy.