Topics

A topic identifies what a publication is about. A topic is a character string that describes the subject of the information that is published in a Publish/Subscribe message. As a subscriber, we can specify a topic or range of topics by using wildcards to receive the information that you require.

A topic identifies what a publication is about and consists of a character string that can be up to 10,240 character long. Topics are key to the successful delivery of messages in a Publish/Subscribe system. Instead of including a specific destination address in each message, a publisher assigns a topic to each message. The queue manager matches the topic with a list of subscribers who subscribe to that topic, and delivers the message to each of those subscribers.

A publisher can control which subscribers receive a publication by choosing carefully the topic that is specified in the message.

The topic of a message does not have to be defined before a publisher can use it; a topic is created when it is specified in a publication or subscription for the first time.

For the latest about topic strings, wildcard characters, special characters, and topic trees, refer to the following information:

  • A topic string can include any character from the Unicode character set, including the space character. However, there are characters that have special meanings: plus sign (+), number sign (#), asterisk (*), and question mark (?). For more information about these characters, see Wildcard schemes in the online product documentation.
  • Topic strings are case-sensitive, and although a null character does not cause an error, do not use null characters in your topic strings. For the latest information about topic strings, see Use topic strings in the online product documentation.
  • Each topic that you define is an element, or node, in the topic tree. For the latest information about topic trees, see Topic trees in the online product documentation.


Wildcards and special characters in topic strings

This topic details the wildcards that are used in the IBM® WebSphere MQ Version 7.0 or later implementation of Publish/Subscribe messaging.

A topic can contain any character in the Unicode character set. However, the following three characters have a special meaning in the Version 7.0 or later Publish/Subscribe:

  • The topic level separator "/".
  • The multilevel wildcard "#".
  • The single-level wildcard "+".

The topic level separator is used to introduce structure into the topic, and can therefore be specified within the topic for that purpose.

Wildcards are a powerful feature of the topic system in IBM MQ Publish/Subscribe. Wildcards allow subscribers to subscribe to more than one topic at a time. The multilevel wildcard and single level wildcard can be used for subscriptions, but they cannot be used within a topic by the publisher of a message.

However, if a publisher uses the characters "+" or "#" together with other characters in any topic level within a topic, these characters are not treated as wildcards, and they do not have any special meaning.