Skip to content

Publish message with QoS = 1

Francois Normandin edited this page Oct 29, 2020 · 4 revisions

The following diagram shows how the MQTT Broker routes the data in a situation with 1 publishing client and 1 subscribing client, both of which use QoS = 1.

The publishing client starts from the Publish API method. The subscribing client ends with an event that the application registered to. Important note: The server sessions have all been merged in a single one, on the diagram, but actually consist of one session per connected client.

In words, the events taking place in the distributed system can be described as:

  1. Client publishes an application message
  2. Client session routes through the established connection to the server (ex. TCP)
  3. Server session decodes the incoming binary data and formats into a Control Packet of type "Publish"
  4. Server session routes the Publish packet to the Server's core engine
  5. Server takes ownership of application message and responds with a Puback message
  6. Server broadcasts to all subscribers (see subscription handling section below)
  7. Server session replies to the publishing client with the Puback response, through the established connection
  8. Client session decodes the incoming binary data and formats into a Control Packet of type "Puback"
  9. Client session routes the Publish packet to the Client's core engine
  10. Client releases application message and notifies the API call that the transaction is acknowledged

Subscription handling (Parallel sequence of events, started in step 6 of the previous list):

  1. Subscribers with a matched topic forward the application message to the subscribed clients
  2. Server session associated with the subscribed client forwards the packet through the established connection
  3. Subscribing Client session decodes the incoming binary data and formats into a Control Packet of type "Publish"
  4. Subscribing Client session routes the Publish packet to the Client's core engine
  5. Subscribing Client takes ownership of application message and responds with a Puback message
  6. Subscribing Client session replies to the server with the Puback response, through the established connection
  7. Server session decodes the incoming binary data and formats into a Control Packet of type "Puback"
  8. Server session routes the Puback packet to the Server's core engine
  9. Server forwards the acknowledgement packet to the subscribers
  10. Subscriber releases application message and considers the transaction has been acknowledged