QoS 2
also: MQTT QoS 2, Quality of Service Level 2
QoS 2 is the highest quality-of-service level in MQTT messaging, guaranteeing exactly-once delivery of messages between client and broker with acknowledgment handshaking.
QoS 2 (Quality of Service level 2) is part of the MQTT protocol specification, commonly used in IoT and messaging systems on Linux. It provides the strongest delivery guarantee by implementing a four-step handshake: PUBLISH → PUBREC → PUBREL → PUBCOMP, ensuring a message is delivered exactly once and no duplicates are created.
Unlike QoS 0 (fire-and-forget) or QoS 1 (at-least-once), QoS 2 trades higher latency and bandwidth overhead for absolute reliability. The broker and client maintain state about in-flight messages until both confirm successful receipt and processing.
Example: In a critical IoT system monitoring industrial equipment, you'd use QoS 2 for alerts that must never be lost or duplicated:
mosquitto_pub -h broker.local -t "alerts/machine1" -q 2 -m "Temperature critical"QoS 2 is slower but ideal for scenarios where message loss or duplication would cause problems, such as financial transactions, medical device readings, or critical control commands.