1wildcard(3) Library Functions Manual wildcard(3)
2
3
4
6 wildcard - Subscription wildcards
7
8 Every MQTT message includes a topic that classifies it. MQTT servers
9 use topics to determine which subscribers should receive messages
10 published to the server.
11
12 Consider the server receiving messages from several environmental
13 sensors. Each sensor publishes its measurement data as a message with
14 an associated topic. Subscribing applications need to know which sensor
15 originally published each received message. A unique topic is thus used
16 to identify each sensor and measurement type. Topics such as
17 SENSOR1TEMP, SENSOR1HUMIDITY, SENSOR2TEMP and so on achieve this but
18 are not very flexible. If additional sensors are added to the system at
19 a later date, subscribing applications must be modified to receive
20 them.
21
22 To provide more flexibility, MQTT supports a hierarchical topic
23 namespace. This allows application designers to organize topics to
24 simplify their management. Levels in the hierarchy are delimited by the
25 '/' character, such as SENSOR/1/HUMIDITY. Publishers and subscribers
26 use these hierarchical topics as already described.
27
28 For subscriptions, two wildcard characters are supported:
29
30 • A '#' character represents a complete sub-tree of the hierarchy and
31 thus must be the last character in a subscription topic string, such
32 as SENSOR/#. This will match any topic starting with SENSOR/, such as
33 SENSOR/1/TEMP and SENSOR/2/HUMIDITY.
34 • A '+' character represents a single level of the hierarchy and is
35 used between delimiters. For example, SENSOR/+/TEMP will match
36 SENSOR/1/TEMP and SENSOR/2/TEMP.
37 Publishers are not allowed to use the wildcard characters in their
38 topic names.
39 Deciding on your topic hierarchy is an important step in your system
40 design.
41
42
43
44Paho MQTT C Client Library Thu Jan 19 2023 wildcard(3)