Fig.1 MQTT Work flow representation
The above Fig.1 represents how the MQTT broker works. The MQTT client
connects to the MQTT broker with the subscribe command. All the
information is organized in a hierarchy of topics. The client is
subscribed to the particular topic name from where the messages have to
be published. For instance, if user needs the temperature sensor value
under the topic temp, then the client first subscribes to the topic
temp. Then the broker fetches the value from the topic name and
publishes it to the client.
MQTT relies on TCP/IP protocol for data transmission protocol. The
client always interacts with the broker, but a system can have multiple
broker servers that exchange data based on their current subscriber’s
topic.