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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.