QoS 2 - Exactly Once QoS 2 is the highest level of service in MQTT and guarantees each message is received
only once by the intended recipients. QoS level involves additional overhead (four-step
handshake) and is the slowest of all service levels. When a receiver gets a QoS 2 packet from the sender, it processes the message and
replies with a publish acknowledgement (PUBREC) packet. If the sender does not get the
PUBREC packet, it resends the PUBLISH packet until it receives an acknowledgement. With
the PUBREC acknowledgment, the sender discards the initial PUBLISH packet. Then, the
sender stores the PUBREC packet and responds with a publish discarded (PUBREL)
packet. Once the receiver gets the PUBREL packet, it can discard all stored states and respond
with a publish complete (PUBCOMP) packet. The sender can now delete the stored PUBREC
packet and the packet identifier is available for reuse.
|