Publish message

The Publish command message is sent from a publisher to a broker, or from a broker to a subscriber, to publish information on a specified topic or topics.

This message is sent to the input queue of a message flow that contains a Publication node. Authority to put a message onto this queue, and to publish on the specified topic or topics, is necessary.

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

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

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

The broker forwards the Publish message to other brokers 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.

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.

This property should not be included in a publication message sent to the broker but is added automatically to publication messages by the broker before those messages are sent to any appropriate subscribers. The value of the <SubPoint> property is the value of the Subscription Point attribute of the Publication node that is handling the publishing.

<PubOpt> (MQPSC_PUBLICATION_OPTION)
The publication options property can take the following values:
RetainPub  
(MQPSC_RETAIN_PUB)

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

IsRetainedPub  
(MQPSC_IS_RETAINED_PUB)

(Can only be set by a broker.) This publication has been retained by the broker. The broker 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 broker that this publication should not be sent to other brokers. All subscribers that registered at this broker 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 broker 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 below.

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.

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 broker before being sent to the subscribers.

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

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

If publications on the same topic are published to different interconnected brokers, 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 broker's 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>