Every IBM MQ queue manager that runs publish/subscribe maintains a topic tree: an in-memory and repository-backed hierarchy of topic strings. When an application publishes to healthcare/claim/adjudicated, the pub/sub engine walks or creates nodes for healthcare, then claim, then adjudicated. Subscriptions registered at healthcare/claim/# or healthcare/+/adjudicated are evaluated against that same tree structure—not against a flat list of queue names. Beginners who treat topic strings as arbitrary labels often design subscriptions that never fire: the publish path has four levels while the subscription pattern only allows three. This tutorial explains what the tree is, how nodes appear, how parents and children relate to wildcards, how topic objects anchor branches, how cluster and administrative topics attach to the tree, monitoring commands, capacity and authority implications, and design practices that keep enterprise event catalogs maintainable.
Think of the topic tree like a file system without files at folders—only path names. The root is implicit. Each segment after a slash is a child of the previous segment. finance is a parent of finance/payment; finance/payment is a parent of finance/payment/posted. A publication always targets a leaf path (the full string), but subscriptions may attach at any node: exact leaf finance/payment/posted, single-level wildcard finance/+/posted, or multi-level finance/payment/#. Authority profiles and PUB/SUB permissions are often granted at a parent node so all children inherit consistent rules on platforms that support subtree authority—verify OAM behavior on your operating system.
| Term | Meaning | Operations note |
|---|---|---|
| Node | One segment or full path entry in the tree | Created when pub/sub traffic references the path |
| Branch | Prefix shared by many leaf topics | Define DEFINE TOPIC at branch for governance |
| Leaf | Full topic string used by a publisher | Highest fan-out if many subs use parent wildcards |
| Orphan publish | String with no matching subscription | Succeeds but copies to zero queues—often confused with failure |
| Overlapping subs | Multiple patterns match one publish | Each match = one put to its DEST queue |
Nodes become active when traffic demands them. The first publish to logistics/shipment/dispatched creates the chain of nodes if they did not exist. Likewise, DEFINE SUB with TOPICSTR('logistics/shipment/#') registers interest and materializes subscription state tied to that branch. Pre-creating DEFINE TOPIC objects does not by itself move messages—it documents branches, sets TOPTYPE and scope attributes, and gives administrators DISPLAY TOPIC handles before applications go live. In regulated environments, change control prefers TOPIC objects on paper first, then application cutover, so the tree does not sprawl with ad hoc strings like TEAM42/BUGFIX/TRY3.
The single-level wildcard + occupies exactly one segment position. Pattern retail/+/shipped matches retail/uk/shipped and retail/us/shipped but not retail/uk/london/shipped because london is a second variable level where only one + was allowed. The multi-level wildcard # must appear as the last character of the pattern (in standard IBM MQ topic syntax) and matches zero or more trailing segments. Pattern retail/# matches retail/uk/shipped and retail/shipped alike. Designing subscriptions is the art of placing + and # at the correct depth in the tree—too broad and you flood downstream apps with unrelated events; too narrow and you maintain hundreds of nearly duplicate subscriptions.
1234567891011* Parent branch object (optional but recommended) DEFINE TOPIC('RETAIL.BRANCH') TOPSTR('retail') TOPTYPE(LOCAL) + DESCR('Retail domain root') * Publications (application or amqspub sample) * Topic string: retail/uk/order/created * Subscriptions: DEFINE SUB('RETAIL.UK.ORDERS') TOPICSTR('retail/uk/order/#') + DESTQL('RETAIL.UK.ORD.SUB') DESTQMGR('QM1') DEFINE SUB('RETAIL.ALL.SHIPPED') TOPICSTR('retail/+/shipped') + DESTQL('RETAIL.SHIP.SUB') DESTQMGR('QM1') DISPLAY SUB('*') TOPICSTR
Topic objects map friendly names to TOPSTR paths. A tree anchored by FINANCE.ROOT with TOPSTR('finance') signals to developers that all finance strings live under that prefix. Cluster topics (TOPTYPE CLUS) extend the tree across queue managers by advertising branches in the cluster repository—see the clustered topics tutorial. Alias topics graft one path onto another without duplicating publishers. The tree is the live structure; objects are the catalog and policy layer on top.
The topic tree is a office tower directory. finance is a floor, payment is a wing, posted is a room number. A visitor (publisher) must announce the full room. Listeners (subscriptions) can wait at a specific room, at any room on a wing ( + ), or anywhere on the floor (#). If you wait in the wrong wing, you never hear the announcement even though the speaker did talk.
Queue names are not hierarchical for routing. Opening PAYMENT.IN does not imply PAYMENT.IN.ERROR. Topic strings inherit prefix semantics in the tree. Migrating from queues to topics requires teaching teams that string design is part of interface contract, not an afterthought. API gateways and JSON schemas should list allowed topic prefixes the same way WSDL lists operations.
The tree itself is lightweight compared to message duplication. A publish that matches fifty subscriptions creates fifty puts. A subscription at prod/# on a busy parent can pull thousands of messages per minute to one DEST queue—CURDEPTH and MAXDEPTH on subscriber queues become the bottleneck, not the tree nodes. Monitor subscriber queue depth alarms separately from topic object counts.
The topic tree is like folders on a computer. You can put a note in Documents/School/Homework.txt. Your friend can say “give me everything in the School folder” or “only Homework files.” IBM MQ uses slashes instead of folders, but the idea of big folders and little folders is the same.
Draw a tree for retail/uk/order/created and retail/us/order/created. Mark where retail/+/order/created and retail/# attach.
Write why retail/+/created does not match retail/uk/store/order/created.
List three DISPLAY commands you would run when a subscriber receives zero messages but publish returns success.
1. The topic tree is primarily:
2. finance/payment matches as parent of finance/payment/posted because:
3. Subscription retail/+/created fails to match retail/uk/store/created because:
4. DEFINE TOPIC before first publish helps operations by: