Topic Strings
Use a topic string to label information that is published as a topic. The topic string is the identifier that is used by the publisher to publish messages. A subscriber can subscribe to a topic, or group of topics by using that identifier. Subscribe to a group of topics that have similar topic strings by using topic-based wildcards.
Topics
A topic string, or topic name, is a character string that identifies the topic of a publish/subscribe message. Topic strings are encoded in UTF-8 and can be constructed from any Unicode character. The topic string is the identifier that is used by the publisher to publish messages. A subscriber can subscribe to that same identifier. A subscriber can subscribe to multiple topics. Wildcards can be used to allow the subscriber to subscribe to a group of topics that have a similar topic string.
Three characters
have special meaning in publish/subscribe. These characters are the
forward slash (/
), the number sign (#
),
and the plus sign (+
).
The use of the special
characters number sign (#
), and plus sign (+
)
is explained in Wildcards. The uses of the special character
forward slash (/
), is explained in the following
section.
- The forward slash (
/
) The topic level separator. Use the
'/'
character to structure the topic into a topic tree.For performance reasons, avoid empty topic levels,
'//'
, if you can. Empty topic levels correspond to nodes in the topic hierarchy with no topic string. A leading or trailing'/'
in a topic string corresponds to a leading or trailing empty node and should be avoided too.
/
) in a
topic string. The maximum topic string length that is accepted by
the Eclipse Amlen server
is 65535 bytes.Examples of topic strings
The following
examples of topics strings use the forward slash sign '/'
.
- "Sport"
- "Sport/Tennis"
- "Sport/Basketball"
- "Sport/Swimming"
- "Sport/Tennis/Finals"
- "Sport/Basketball/Finals"
- "Sport/Swimming/Finals"