In MQTT, topics are structured in a hierarchy separated by slashes. Which of the following represents a valid topic hierarchy for a smart home system?
Think about how MQTT topics use slashes to separate levels.
MQTT topics use forward slashes '/' to separate levels in the hierarchy. Backslashes, dots, or dashes are not valid separators.
What topics will a client receive if it subscribes to home/+/temperature?
The '+' wildcard matches exactly one level in the topic hierarchy.
The '+' wildcard matches exactly one level, so home/+/temperature matches topics like home/livingroom/temperature and home/kitchen/temperature, but not home/livingroom/humidity.
You want to restrict clients so they can only publish to topics under devices/ and subscribe to topics under sensors/. Which configuration snippet correctly enforces this in a typical MQTT broker ACL file?
Remember that '#' matches all subtopics and the ACL syntax requires specifying publish and subscribe permissions.
The ACL line publish devices/# allows publishing to all topics starting with devices/. Similarly, subscribe sensors/# allows subscribing to all topics under sensors/. Other options either reverse permissions or use incorrect syntax.
A client subscribes to home/+/temperature but does not receive messages published to home/livingroom/humidity. What is the most likely cause?
Check if the published topic matches the subscribed topic pattern exactly.
The subscription home/+/temperature matches topics with exactly three levels where the last is 'temperature'. Publishing to home/livingroom/humidity will not match and thus no messages are received.
You are designing an MQTT topic hierarchy for a city-wide sensor network with multiple sensor types in many locations. Which topic hierarchy design best supports easy filtering by location and sensor type?
Consider which topic levels you want to filter on first when subscribing.
Placing location before sensor_type allows subscribers to filter all sensors in a location easily, or filter by sensor type within a location. This is more intuitive for city-wide deployments.