// Module included in the following assemblies:
//
// assembly-standard-address-types.adoc

[id='con-standard-topic-{context}']
= Topic
// !standard.address.topic.shortDescription:A publish-subscribe topic
// !standard.address.topic.longDescription:start
The topic address type supports the publish-subscribe messaging pattern where there are 1..N producers and 1..M consumers. Each message published to a topic address is forwarded to all subscribers for that address. A subscriber can also be durable, in which case messages are kept until the subscriber has acknowledged them.
// !standard.address.topic.longDescription:stop

NOTE: If you create a subscription on a topic, any senders to that topic must specify the `topic` capability.

== Hierarchical topics and wildcards

A client receiving from a topic address can specify a wildcard address with the topic address as the root. The wildcard behavior follows the MQTT syntax:

* `/` is a separator
* `+` matches one level
* `#` matches one or more levels

So, for example:

* `a/#/b` matches `a/foo/b`, `a/bar/b`, and `a/foo/bar/b`

* `a/+/b` matches `a/foo/b` and `a/bar/b`, but would not match `a/foo/bar`

In the standard address space, the first level must always be a defined topic address; that is, `#` and `+` are not valid as the first characters of a subscribing address.

== Known issue with creating a subscriber on a hierarchical topic

A known issue exists where creating a subscriber on a hierarchical topic in {ProductName} causes the broker to instead create it as a competing consumer (handling the address like a queue rather than a topic). For more information about the specific workaround for your client, see the applicable client example section in link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#assembly-connecting-applications-messaging[Connecting applications to {ProductName}].

