Publish message

The Publish command message is put to a queue, or from a queue manager to a subscriber, to publish information on a specified topic or topics.

Authority to put a message onto a queue and authority to publish information on a specified topic or topics is necessary.

If the user has authority to publish information on some, but not all, topics, only those topics are used to publish; a warning response indicates which topics are not used to publish.

If a subscriber has any matching subscriptions, the queue manager forwards the Publish message to the subscriber queues defined in the corresponding Register Subscriber command messages.

See Queue Manager Response message for details of the message descriptor (MQMD) parameters needed when sending a command message to the queue manager, and used when a queue manager forwards a publication to a subscriber.

The queue manager forwards the Publish message to other queue managers in the network that have matching subscriptions, unless it is a local publication.

Publication data, if any, is included in the body of the message. The data can be described in an <mcd> folder in the NameValueData field of the MQRFH2 header.


Properties

    Command (MQPSC_COMMAND)
    The value is Publish (MQPSC_PUBLISH).

    This property must be specified.

    Topic (MQPSC_TOPIC)
    The value is a string that contains a topic that categorizes this publication. No wildcard characters are allowed.

    We must add the topic to the namelist SYSTEM.QPUBSUB.QUEUE.NAMELIST, see Adding a stream for instructions on how to complete this task.

    This property must be specified, and can optionally be repeated for as many topics as needed.

    SubPoint (MQPSC_SUBSCRIPTION_POINT)
    The subscription point on which the publication is published.

    In WebSphere Event Broker Version 6.0, the value of the <SubPoint> property is the value of the Subscription Point attribute of the Publication node that is handling the publishing.

    In IBM WebSphere MQ Version 7.0.1, the value of the <SubPoint> property must match the name of a subscription point. See Adding a subscription point.

    PubOpt (MQPSC_PUBLICATION_OPTION)
    The publication options property can take the following values:

      RetainPub   
      (MQPSC_RETAIN_PUB)

      The queue manager is to retain a copy of the publication. If this option is not set, the publication is deleted as soon as the queue manager has sent the publication to all its current subscribers.

      IsRetainedPub   
      (MQPSC_IS_RETAINED_PUB)

      (Can only be set by a queue manager.) This publication has been retained by the queue manager. The queue manager sets this option to notify a subscriber that this publication was published earlier and has been retained, provided that the subscription has been registered with the InformIfRetained option. It is set only in response to a Register Subscriber or Request Update command message. Retained publications that are sent directly to subscribers do not have this option set.

      Local   
      (MQPSC_LOCAL)

      This option tells the queue manager that this publication must not be sent to other queue managers. All subscribers that registered at this queue manager receive this publication if they have matching subscriptions.

      OtherSubsOnly   
      (MQPSC_OTHER_SUBS_ONLY)

      This option allows simpler processing of conference-type applications, where a publisher is also a subscriber to the same topic. It tells the queue manager not to send the publication to the publisher's subscriber queue even if it has a matching subscription. The publisher's subscriber queue consists of its QMgrName, QName, and optional CorrelId, as described in the following list.

      CorrelAsId   
      (MQPSC_CORREL_ID_AS_IDENTITY)

      The CorrelId in the MQMD (which must not be zero) is part of the publisher's subscriber queue, in applications where the publisher is also a subscriber.

      None   
      (MQPSC_NONE)

      All options take their default values. This has the same effect as omitting the publication options property. If other options are specified at the same time, None is ignored.

    We can have more than one publication option by introducing additional <PubOpt> elements.

    The default, if this property is omitted, is that no publication options are set.

    PubTime (MQPSC_PUBLISH_TIMESTAMP)
    The value is an optional publication timestamp set by the publisher. It is 16 characters long with format:
       YYYYMMDDHHMMSSTH
    

    using Universal Time. This information is not checked by the queue manager before being sent to the subscribers.

    SeqNum (MQPSC_SEQUENCE_NUMBER)
    The value is an optional sequence number set by the publisher.

    It must be incremented by 1 with each publication. However, this is not checked by the queue manager, which merely transmits this information to subscribers.

    If publications on the same topic are published to different interconnected queue managers, it is the responsibility of the publishers to ensure that sequence numbers, if used, are meaningful.

    QMgrName (MQPSC_Q_MGR_NAME)
    The value is a string containing the name of the queue manager for the publisher's subscriber queue, in applications where the publisher is also a subscriber (see OtherSubsOnly ).

    If this property is omitted, the default is the ReplyToQMgr name in the message descriptor (MQMD). If the resulting name is blank, it defaults to the name of the queue manager.

    QName (MQPSC_Q_NAME)
    The value is a string containing the name of the publisher's subscriber queue, in applications where the publisher is also a subscriber (see OtherSubsOnly ).

    If this property is omitted, the default is the ReplyToQ name in the message descriptor (MQMD), which must not be blank if OtherSubsOnly is set.


Example

Here are some examples of NameValueData for a Publish command message.

The first example is for a publication sent by the match simulator in the sample application to indicate that a match has started.
 <psc>
   <Command>Publish</Command>
   <Topic>Sport/Soccer/Event/MatchStarted</Topic>
 </psc>
The second example is for a retained publication. The latest score in the match between Team1 and Team2 is published.
 <psc>
   <Command>Publish</Command>
   <PubOpt>RetainPub</PubOpt>
   <Topic>Sport/Soccer/State/LatestScore/Team1 Team2</Topic>
 </psc>
Parent topic: Queued publish/subscribe command messages