Process Flow - QoS levels (0, 1, 2)
Start: Publish Message
Check QoS Level
QoS 0
Send
No Ack
Done
Done
The flow shows how a message is published with different QoS levels, each with increasing delivery guarantees and acknowledgement steps.
Publish message with QoS 1 Send message Wait for PUBACK If no PUBACK, resend End
| Step | QoS Level | Action | Acknowledgement | Result |
|---|---|---|---|---|
| 1 | 0 | Send message once | No ack expected | Message sent, no retry |
| 2 | 1 | Send message | Wait for PUBACK | If PUBACK received, done |
| 3 | 1 | No PUBACK received | Timeout | Resend message |
| 4 | 1 | PUBACK received after resend | PUBACK received | Done |
| 5 | 2 | Send PUBLISH message | Wait for PUBREC | If PUBREC received, send PUBREL |
| 6 | 2 | Send PUBREL | Wait for PUBCOMP | If PUBCOMP received, done |
| 7 | 2 | No PUBREC received | Timeout | Resend PUBLISH |
| 8 | 2 | No PUBCOMP received | Timeout | Resend PUBREL |
| 9 | 2 | PUBCOMP received | PUBCOMP received | Done |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | After Step 5 | After Step 6 | After Step 7 | After Step 8 | Final |
|---|---|---|---|---|---|---|---|---|---|---|
| Message Sent | No | Yes (QoS0) | Yes (QoS1) | Yes (QoS1 resend) | Yes (QoS1) | Yes (QoS2) | Yes (QoS2) | Yes (QoS2 resend) | Yes (QoS2 resend PUBREL) | Yes (QoS2) |
| Acknowledgement Received | No | N/A | No | No | Yes (PUBACK) | No | Yes (PUBREC) | No | Yes (PUBCOMP) | Yes |
| Retries | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 |
QoS Levels in MQTT: - QoS 0: Send once, no ack, possible loss - QoS 1: Send, wait PUBACK, resend if no ack - QoS 2: Two-phase ack (PUBREC, PUBCOMP), exactly once delivery Each level increases delivery guarantee and network traffic