Topic trees

Each topic that you define is an element, or node, in the topic tree. The topic tree can either be empty to start with or contain topics that have been defined previously using MQSC or PCF commands. You can define a new topic either by using the create topic commands or by specifying the topic for the first time in a publication or subscription.

Although you can use any character string to define a topic's topic string, it is advisable to choose a topic string that fits into a hierarchical tree structure. Thoughtful design of topic stings and topic trees can help you with the following operations:
  • Subscribing to multiple topics.
  • Establishing security policies.

Although you can construct a topic tree as a flat, linear structure, it is better to build a topic tree in a hierarchical structure with one or more root topics. For more information about security planning and topics, see Publish/subscribe security.

Figure 1 shows an example of a topic tree with one root topic.
Figure 1. Example of a topic tree
This figure shows a topic tree. At the top of the tree is the root node USA. The next level of the tree shows two nodes beneath the root node. These nodes are Alabama and Alaska. Beneath the nodes at this level are the nodes Auburn, Mobile, and Montgomery, under Alabama, and the node Juneau, under Alaska.

Each character string in the figure represents a node in the topic tree. A complete topic string is created by aggregating nodes from one or more levels in the topic tree. Levels are separated by the "/" character. The format of a fully specified topic string is: "root/level2/level3".

The valid topics in the topic tree shown in Figure 1 are:
  • "USA"
  • "USA/Alabama"
  • "USA/Alaska"
  • "USA/Alabama/Auburn"
  • "USA/Alabama/Mobile"
  • "USA/Alabama/Montgomery"
  • "USA/Alaska/Juneau"

When you design topic strings and topic trees, remember that the queue manager does not interpret, or attempt to derive meaning from, the topic string itself. It simply uses the topic string to send selected messages to subscribers of that topic.

The following principles apply to the construction and content of a topic tree:
  • There is no limit to the number of levels in a topic tree.
  • There is no limit to the length of the name of a level in a topic tree.
  • There can be any number of "root" nodes; that is, there can be any number of topic trees.