Publications

Publications are messages that are sent by an application to the Publish/Subscribe Engine. The Publish/Subscribe Engine then sends the messages on to any applications that have subscribed to receive the messages.

The Publish/Subscribe Engine can handle publications that it receives in different ways, depending on the type of information contained in the publication.

State and event information

Publications can be categorized by the type of information that they contain:
State publications
State publications contain information about the current state of something, such as the price of stock or the current score at a soccer match. When something happens (for example, the stock price changes or the soccer score changes), the previous state information is no longer required because it is superseded by the new information.
A subscriber application wants to receive the current version of the state information on startup, and to be sent new information whenever the state changes.
Event publications
Event publications contain information about individual events that occur, such as a trade in some stock or the scoring of a particular goal. Each event is independent of other events.
A subscriber wants to receive information about events as they happen.

Retained publications

By default, when the Publish/Subscribe Engine has sent a publication to all interested subscribers, the Publish/Subscribe Engine deletes the publication. This type of processing is suitable for event information but is not always suitable for state information. A publisher can specify that the Publish/Subscribe Engine must keep a copy of a publication, which is then called a retained publication. The copy can be sent to subsequent subscribers who register an interest in the topic. This means that new subscribers do not have to wait for information to be published again before they receive it. For example, a subscriber who registers a subscription to a stock price would receive the current stock price straightaway, without waiting for the stock price to change (and, therefore, be re-published).

The Publish/Subscribe Engine retains only one publication for each topic, so the old publication is deleted when a new one arrives. So, ensure that only one publisher is sending retained publications on each topic.

Subscribers can specify that they do not want to receive retained publications, and existing subscribers can ask for duplicate copies of retained publications to be sent to them.

For more information about how to decide whether to use retained publications, see Retained publications in the IBM® MQ online product documentation.