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