MQTT Topics Explained

mqtt-topics
Spread the love

An MQTT topic consists of one or more levels each topic level is separated by forward slash, topics are very lightweight and dynamic. So, an MQTT is quite different from other messaging systems.

MQTT Topics

You might know you can have literally millions of topics in your system and it’s absolutely fine for your broker because there is a super-lightweight structure and their dynamic.

you don’t need to create topics beforehand as soon as you want to use a topic, a client can just publish to this topic and or subscribe to it.

MQTT Wildcard Pattern

The great thing about topics in MQTT is a wildcard pattern. we have a plus wildcard and hashtag wildcard.

The plus wildcard is used in the middle beginning or the end of the topic and this indicates for the broker that the subscription you want to make at the broker as a client should match everything on this level.

We also have the hashtag wildcard which means if you imagine that the topic space is a tree everything after the hashtag would be selected automatically for your subscription.

This topic wildcards are extremely important because of these topics wildcards you can have literally millions of topics while you can still use just a few subscriptions and get a lot of the data streams.

So, just because you’re publishing to millions of topics it doesn’t mean that you also need to subscribe to millions of topics because if you use the wildcards in a very good and clever way you get every part of the data stream.

Also Read: Features of MQTT


Spread the love

Be the first to comment

Leave a Reply

Your email address will not be published.


*