Topics
What Are Topics?
In RelayX, a topic is a named address that messages are published to and delivered from.
Topics exist for one reason: routing messages.
When a producer publishes a message, it publishes it to a topic.
When a subscriber subscribes, it subscribes to one or more topics.
During normal operation, messages published to a topic are delivered to all subscribers of that topic.
Topics do not process messages.
Topics do not change message behavior.
Topics do not add delivery guarantees.
They only decide which subscribers receive which messages.
How Topics Are Used
Topics are represented as strings. These strings are used by RelayX to match published messages with subscriptions.
Common examples:
devices.kitchen.temperatureorders.completed.us.nycbroadcast
Topics are often written in a hierarchical form to make routing easier to reason about, but the hierarchy itself does not change how messages behave.
More about matching behavior is explained in the Wildcard Behaviour section.
Topic Naming Rules
To ensure consistent behavior across all SDKs, topic names must follow these rules:
-
No dollar signs (
$)
The topic string must not contain the$character anywhere. -
Topics cannot contain spaces and cannot be empty
-
Wildcard placement
>may appear only at the end of a topic and only after a.
-
Topic format
token[.token …][.> or .*]Token definition
Each token consists of one or more characters from:
A-Za-z0-9_*~- -
Token restrictions
- Tokens cannot be empty
- No consecutive dots (
..) - No leading or trailing dots
-
Case sensitivity
Topic names are case-sensitive.
Foo.Barandfoo.barare different topics.
Wildcard Behaviour
Wildcards allow subscribers to receive messages from multiple related topics without subscribing to each topic individually.
Wildcards are only supported in subscriptions, not when publishing.
Asterisk (*)
Matches exactly one token.
devices.*.temperaturematches:devices.kitchen.temperaturedevices.livingroom.temperature
Greater-than (>)
Matches one or more tokens at the end of a topic and must be the final token.
-
devices.>matches:devices.kitchen.temperaturedevices.kitchen.humiditydevices.livingroom.temperature
-
>matches all topics
Mixing wildcards
You may use multiple * tokens and mix * with >.
*.us.>matches:temp.us.nychumidity.us.la.outdoor
Wildcards affect subscription matching only.
They do not affect message ordering, delivery guarantees, or retries.
Reserved Topics
The following topics are reserved and cannot be published to or subscribed to by clients:
CONNECTEDDISCONNECTEDRECONNECTRECONNECTEDRECONNECTINGRECONN_FAILMESSAGE_RESEND
What Topics Do Not Do
Topics do not:
- Control message ordering
- Control retries or redelivery
- Affect deduplication
- Isolate failures between subscribers
- Act as queues or workflow stages
All message semantics are defined by the messaging system itself, not by the topic.
Examples
Valid topics
sensor.data.temperatureuser.signup.europe.londonfoofoo.barsystem.error.critical*foo.**.barfoo.*.baz>foo.>foo.bar.>*.*.>alpha_betaalpha-betaalpha~betametric.cpu.loadmetrics.>
Invalid topics
$foofoo$foo.$.barfoo..bar.foofoo.foo.>.bar>foofoo>barfoo.>barfoo.bar.>.foo barfoo/barfoo#bar...>foo...>.foo,bazαbetafoo|barfoo;barfoo:barfoo%barfoo.*.>.barfoo.*.>.foo.*..barfoo>
Join our Discord server, post your concern & someone from our team will help you out ✌️