Skip to content

Difference between retain and QoS

Camilo Sperberg edited this page Apr 18, 2018 · 1 revision

These two options may be confusing at first, but are actually quite simple to differentiate.

A retain bit -as is the QoS level- are both set in a PUBLISH packet. However, when the client sends a PUBLISH packet with the retain bit to the broker, we are mandating the broker to persist the packet up until it is overwritten with another PUBLISH packet.
This allows the broker to store a message and when a new subscription is established, the last retained message, if any, on each matching topic name MUST be sent to the subscriber.

QoS on the other hand, does not store the message for future clients. QoS will only handle that the message effectively arrives at it's destination.

Clone this wiki locally