Message Queuing Telemetry Transport MQTT is a bi-directional lightweight network communication protocol protocol that transports messages between low power devices and can run over TCP/IP. The MQTT protocol is based on the principle of publishing messages and subscribing to topics to exchange data between clients and the server.
MQTT subscribe publish flow
Example:


Temperature sensor: This sensor publish a value 20 Celsius degrees to the Mqtt Broker. A device that needs that value must subscribe to the Mqtt Broker to receive it. The temperature sensor is the publisher and the mobile the Subscriber.

A client can subscribe to individual or multiple topics

Example:

Topics:

house/groundfloor/livingroom/temperature
house/groundfloor/livingroom/lightswitch
house/groundfloor/garage/temperature
house/firstfloor/bedroom/temperature

There is a multi-level wildcard # and a singel-level wildcard +

Green: Does receive Publisher messages.
Red: Does not receive Publisher messages.

house/# produce the following results:

house/groundfloor/livingroom/temperature
house/groundfloor/livingroom/lightswitch
house/groundfloor/garage/temperature
house/firstfloor/bedroom/temperature

house/groundfloor/# produce the following results:

house/groundfloor/livingroom/temperature
house/groundfloor/livingroom/lightswitch
house/groundfloor/garage/temperature

house/firstfloor/bedroom/temperature

house/groundfloor/+/temperature produce the following results:

house/groundfloor/livingroom/temperature
house/groundfloor/livingroom/lightswitch
house/groundfloor/garage/temperature
house/firstfloor/bedroom/temperature