wildcard(3)
πΈ NAME πΈ
wildcard β Subscription wildcards π
okay bestie, gather round, because this one is lowkey the whole personality of MQTT and you're gonna be obsessed β¨
Every single MQTT message carries a topic, and that topic is basically the message's little name tag β it's what classifies it. MQTT servers use topics to figure out which subscribers should get a message that got published to the server. no topic, no vibe check, no delivery π
π¦ so likeβ¦ imagine a bunch of sensors π¦
Picture the server getting messages from several environmental sensors. Each sensor publishes its measurement data as a message with an associated topic. And subscribing applications need to know which sensor originally published each received message. So a unique topic is used to identify each sensor and each measurement type. Topics like SENSOR1TEMP, SENSOR1HUMIDITY, SENSOR2TEMP and so on totally achieve this β but they are not very flexible, and that's the problem. π If additional sensors get added to the system at a later date, subscribing applications must be modified to receive them. it's giving maintenance nightmare fr fr.
π the glow-up: hierarchical topics π
To provide more flexibility, MQTT supports a hierarchical topic namespace. This lets application designers organize topics to simplify their management. Levels in the hierarchy are delimited by the '/' character, such as SENSOR/1/HUMIDITY. Publishers and subscribers use these hierarchical topics as already described. see? structure. elegance. main character energy π
β¨ the two wildcard characters β¨
For subscriptions, two wildcard characters are supported β and you're gonna stan both:
- The
'#'character represents a complete sub-tree of the hierarchy, and thus must be the last character in a subscription topic string, such asSENSOR/#. This will match any topic starting withSENSOR/, such asSENSOR/1/TEMPandSENSOR/2/HUMIDITY. it's giving "everything under here, thank you" π«Ά - The
'+'character represents a single level of the hierarchy and is used between delimiters. For example,SENSOR/+/TEMPwill matchSENSOR/1/TEMPandSENSOR/2/TEMP. one level only, no more no less, periodt π
π¨ and here's the rule that will humble you: Publishers are not allowed to use the wildcard characters in their topic names. that's a subscribers-only thing, iykyk π
Deciding on your topic hierarchy is an important step in your system design. like genuinely, don't skip it, it's the blueprint of the whole thing π
mwah π that was wildcard(3), brought to you by the Paho MQTT C Client Library, dated Tue Jun 2 2026 00:00:00. go forth and structure your topics, bestie π
π¦ where this page comes from
- fedora 44: paho-c-devel 1.3.16-1.fc44 Β· BSD-3-Clause AND EPL-2.0
- fedora 44: paho-c-devel 1.3.16-1.fc44 Β· BSD-3-Clause AND EPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms