Bird
Raised Fist0
IOT Protocolsdevops~20 mins

Wildcard subscriptions (+ and #) in IOT Protocols - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
MQTT Wildcard Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the '+' wildcard in MQTT topic subscriptions
In MQTT, what does the '+' wildcard match in topic subscriptions?
AIt matches zero or more topic levels at the position of the '+'
BIt matches exactly one topic level at the position of the '+'
CIt matches the entire topic string regardless of levels
DIt matches only the last topic level in the topic string
Attempts:
2 left
💡 Hint
Think about how '+' works compared to '#' in MQTT topics.
🧠 Conceptual
intermediate
1:30remaining
Understanding the '#' wildcard in MQTT topic subscriptions
In MQTT, what does the '#' wildcard match in topic subscriptions?
AIt matches zero or more topic levels including the current and all following levels
BIt matches exactly one topic level at the position of the '#'
CIt matches only the first topic level in the topic string
DIt matches only topics without any sub-levels
Attempts:
2 left
💡 Hint
Consider how '#' differs from '+' in matching topic levels.
💻 Command Output
advanced
2:00remaining
Output of MQTT subscription matching with '+' wildcard
Given the subscription topic filter home/+/temperature, which published topic will match this subscription?
Ahome/temperature
Bhome/kitchen/livingroom/temperature
Chome/kitchen/temperature
Dhome//temperature
Attempts:
2 left
💡 Hint
Remember '+' matches exactly one level, no more, no less.
💻 Command Output
advanced
2:00remaining
Output of MQTT subscription matching with '#' wildcard
Given the subscription topic filter devices/sensors/#, which published topic will NOT match this subscription?
Adevices/sensors
Bdevices/sensors/temperature
Cdevices/sensors/temperature/room1
Ddevices/actuators/temperature
Attempts:
2 left
💡 Hint
The '#' wildcard matches zero or more levels after its position.
❓ Troubleshoot
expert
2:30remaining
Troubleshooting MQTT subscription with mixed wildcards
A client subscribes to the topic filter building/+/floor/#. Which of the following published topics will NOT be received by the client?
Abuilding/room1/temperature/floor
Bbuilding/room2/floor
Cbuilding/room3/floor/room4/humidity
Dbuilding/room1/floor/temperature
Attempts:
2 left
💡 Hint
Check the position of the wildcards and the topic levels carefully.

Practice

(1/5)
1. What does the MQTT wildcard + represent in topic subscriptions?
easy
A. It matches zero or more topic levels.
B. It matches exactly one topic level.
C. It matches the entire topic string.
D. It matches only the last topic level.

Solution

  1. Step 1: Understand the + wildcard meaning

    The + wildcard matches exactly one topic level in MQTT subscriptions.
  2. Step 2: Compare with other wildcards

    The # wildcard matches zero or more levels, so it is different from +.
  3. Final Answer:

    It matches exactly one topic level. -> Option B
  4. Quick Check:

    + = one level [OK]
Hint: Remember: + means one level only [OK]
Common Mistakes:
  • Confusing + with # wildcard
  • Thinking + matches multiple levels
  • Assuming + matches zero levels
2. Which of the following is the correct MQTT subscription syntax to match all topics under home/kitchen including sub-levels?
easy
A. home/kitchen/#
B. home/+/kitchen
C. home/kitchen/+
D. home/#/kitchen

Solution

  1. Step 1: Identify the wildcard for all sub-levels

    The # wildcard matches all remaining topic levels, including zero or more sub-levels.
  2. Step 2: Apply to the topic home/kitchen

    Using home/kitchen/# subscribes to home/kitchen and any deeper topics like home/kitchen/temperature.
  3. Final Answer:

    home/kitchen/# -> Option A
  4. Quick Check:

    # matches all sub-levels [OK]
Hint: Use # to catch all subtopics under a path [OK]
Common Mistakes:
  • Using + instead of # for multiple levels
  • Placing # in the middle of the topic
  • Using invalid syntax like # in the middle
3. Given the subscription building/+/temperature, which of these topics will be matched?
medium
A. building/floor1/temperature
B. building/floor1/room1/temperature
C. building/temperature
D. building/floor1/humidity

Solution

  1. Step 1: Understand the + wildcard position

    The + wildcard matches exactly one topic level between building and temperature.
  2. Step 2: Check each topic against the pattern

    Topic building/floor1/temperature matches because floor1 fills the + wildcard. Others either have too many or too few levels or wrong last level.
  3. Final Answer:

    building/floor1/temperature -> Option A
  4. Quick Check:

    + matches one level only [OK]
Hint: + matches exactly one level between slashes [OK]
Common Mistakes:
  • Matching topics with extra levels
  • Ignoring the exact position of +
  • Assuming + matches zero levels
4. You wrote the subscription sensor/#/temperature but it does not work. What is the problem?
medium
A. The subscription is missing a leading slash.
B. The + wildcard should be used instead of # here.
C. The topic levels are case sensitive and must be lowercase.
D. The # wildcard must be at the end of the topic filter.

Solution

  1. Step 1: Recall the rule for # wildcard placement

    The # wildcard must be the last character in the topic filter and can only appear once.
  2. Step 2: Analyze the subscription sensor/#/temperature

    Here, # is in the middle, which is invalid syntax and causes the subscription to fail.
  3. Final Answer:

    The # wildcard must be at the end of the topic filter. -> Option D
  4. Quick Check:

    # only at end [OK]
Hint: # must be last in topic filter [OK]
Common Mistakes:
  • Placing # in the middle of topic
  • Confusing + and # usage
  • Ignoring MQTT topic syntax rules
5. You want to subscribe to all topics under office but only one level deep, such as office/room1 and office/room2, but not office/room1/temperature. Which subscription should you use?
hard
A. office/+/+
B. office/#
C. office/+
D. office

Solution

  1. Step 1: Understand the requirement for one level deep

    You want to match topics exactly one level below office, like office/room1.
  2. Step 2: Choose the correct wildcard

    The + wildcard matches exactly one level, so office/+ matches office/room1 but not office/room1/temperature.
  3. Final Answer:

    office/+ -> Option C
  4. Quick Check:

    One level deep = use + wildcard [OK]
Hint: Use + for exactly one sub-level [OK]
Common Mistakes:
  • Using # which matches all levels
  • Using multiple + wildcards incorrectly
  • Not including any wildcard
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard