Multi-level wildcards

Multi-level wildcards, indicated by a number/hashtag character (#), can be used to subscribe to various topics at once—as the name suggests—multiple levels deep. Below, you can see individual topic names that we could subscribe to one by one:

/kitchen/smart-coffee-machine/temperature/kitchen/smart-coffee-machine/status/kitchen/ceiling-light/status

But, instead of subscribing to them individually, we could simply subscribe to them all at once using a wildcard character:

/kitchen/#

This means I want to subscribe to everything that happens in this channel and all of its sub-channels. As the name suggests, this is multiple levels deep, so all of these messages would be included in this topic filter:

/kitchen/kitchen/smart-coffee-machine ...

Get Hands-On Internet of Things with MQTT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.