Wildcards on topics

If publishing data to another client through the broker it is necessary to specify the full topic name: for receiving messages clients can subscribe using the wildcard level for topics. Wildcards are single level + and multi-level #:

  1. Single-level +.
  2. Using the + in the subscription level for a topic means that instead of + can be any value.
  3. If you want to build a display panel to show the temperature from your house, you build modules that read the temperature from every room and publish it on topics such as:
myHouse/groundFloor/livingroom/temperature
myHouse/groundFloor/kitchen/temperature
  1. myHouse/firstFloor/bedroom/temperature and the display module will subscribe to:
myHouse/groundFloor/+/temperature
  1. Every time a temperature module located on the ground floor is publishing some message on its topic, the display module will receive it, so it is not necessary to subscribe on each topic, but it will not receive the data from the following topics:
myHouse/groundFloor/livingroom/humidity
myHouse/groundFloor/kitchen/light
  1. Multi-level #.
  2. Using # in the subscribed topic level client will receive all messages from that level down.
  3. If the display panel is subscribing to topic.
  4. myHouse/groundFloor/# that means that it will receive all the messages published on topics that start with myHouse/groundFloor.
  5. If a client subscribes to #, the topic will receive all the messages published within that broker.
  6. Special topics $.
  7. If you want to monitor internal statistics of the broker then you need to subscribe to the $SYS topics.
  1. Here are examples of what you can get:
$SYS output example
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.241