View Single Post
Posts: 2 | Thanked: 3 times | Joined on Dec 2010
#200
Originally Posted by xur17 View Post
I tried playing around with the qos values, but I am not sure that I understand them. What is the best way to send a message, and ensure that it gets delivered, even if the client is offline?
You'll want to use QoS 1 or 2.

QoS 0 offers no guarantees at all - it's just fire and forget.
QoS 1 means that the message will be delivered at least once - but may be delivered more than once.
QoS 2 means that the message will be delivered exactly once.

Increasing the QoS level increases the overhead and latency a bit due to the handshaking required. QoS 0 is just a single publish message, QoS 1 is a publish then an ack, and QoS 2 has a further two handshake messages.

With regards to disconnected operation, that's covered as well. You'd have your clients connecting with "clean session" set to false. This means that on disconnect, the broker will maintain its subscriptions and queue messages that come in on that subscription, but only where the subscription and messages are QoS 1 or 2.

There is a caveat - the broker won't store an unlimited amount of these messages, so there's no hard guarantee. You should look at the max_queued_messages config variable to change the maximum number of queued messages per disconnected client.