Topics
MQTT messages are published to topics. Topics are hierarchical strings separated by /.
Example topics:
sensors/office/temp
sensors/office/humidity
factory/line1/motor/status
Topics help organize message streams and allow subscribers to receive only the data they are interested in.
Wildcards
MQTT supports two wildcard operators for subscriptions:
| Wildcard | Meaning | Example |
|---|---|---|
+ |
Matches a single topic level | sensors/+/temp matches sensors/office/temp |
# |
Matches all remaining topic levels | sensors/# matches all topics under sensors/ |
Subscriptions are stored in a subscription tree structure optimized for MQTT topic matching.
Best Practices
Good topic design improves scalability, readability, and maintainability.
Recommended practices:
- Use hierarchical topic structures
- Keep naming consistent
- Avoid unnecessary topic depth
- Use predictable naming conventions
Examples:
factory/line1/temp
factory/line1/humidity
factory/line2/temp
Avoid:
- Overly long topics
- Inconsistent naming
- Embedding dynamic metadata unnecessarily
Ready to take the next steps?
Managed LavinMQ instance via CloudAMQP
LavinMQ has been built with performance and ease of use in mind - we've benchmarked a throughput of about 1,000,000 messages/sec . You can try LavinMQ without any installation hassle by creating a free instance on CloudAMQP. Signing up is a breeze.
Get started with CloudAMQP ->Help and feedback
We welcome your feedback and are eager to address any questions you may have about this piece or using LavinMQ. Join our Slack channel to connect with us directly. You can also find LavinMQ on GitHub.