0
0
IOT Protocolsdevops~5 mins

Wildcard subscriptions (+ and #) in IOT Protocols - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the '+' wildcard represent in MQTT topic subscriptions?
The '+' wildcard matches exactly one level in the topic hierarchy. It acts like a placeholder for any single topic name at that level.
Click to reveal answer
beginner
What does the '#' wildcard represent in MQTT topic subscriptions?
The '#' wildcard matches any number of levels, including zero, in the topic hierarchy. It must be the last character in the subscription.
Click to reveal answer
beginner
How would you subscribe to all topics under 'home/kitchen' using wildcards?
Use the subscription 'home/kitchen/#' to receive messages from 'home/kitchen' and all its subtopics.
Click to reveal answer
intermediate
Can the '+' wildcard be used multiple times in a single MQTT subscription?
Yes, '+' can be used multiple times to match one level at each position in the topic hierarchy.
Click to reveal answer
intermediate
Why must the '#' wildcard be the last character in an MQTT subscription?
Because '#' matches all remaining levels, placing it last ensures the subscription covers all subtopics beyond that point without ambiguity.
Click to reveal answer
What does the MQTT subscription 'home/+/temperature' match?
AOnly the topic 'home/+/temperature'
BAll topics starting with 'home/temperature'
CAll topics with 'home' as first level, any second level, and 'temperature' as third level
DAll topics under 'home' regardless of levels
Which MQTT subscription matches all topics under 'office' including sublevels?
Aoffice/+
Boffice/#
C#/office
D+/office/#
Is 'home/#/temperature' a valid MQTT subscription?
ANo, '#' must be the last character
BYes, it matches all topics under 'home' with 'temperature' at the end
CYes, but only matches 'home/#/temperature' literally
DNo, '+' should be used instead of '#'
What does the subscription '+/sensor/#' match?
AAll topics with 'sensor' anywhere
BOnly topics starting with '+/sensor/'
COnly topics with exactly two levels
DAny topic with any first level, 'sensor' as second level, and any subtopics after
Which wildcard matches exactly one topic level in MQTT?
A+
B#
C*
D?
Explain how the '+' and '#' wildcards work in MQTT topic subscriptions and give an example of each.
Think about how you can listen to specific or broad topic patterns.
You got /3 concepts.
    Describe why the '#' wildcard must be the last character in an MQTT subscription and what happens if it is not.
    Consider how MQTT interprets topic hierarchies.
    You got /3 concepts.