MQTT Is Not a Message Queue: Why Persistent Sessions and QoS Matter for IoT Data
A team building an IoT system lost data from over 200 devices when a Python worker restarted during a deployment, with no error logs or dead letters. The article explains that MQTT is a lightweight publish/subscribe protocol rather than a true message queue, so messages are only delivered to active subscribers unless specific settings are enabled. It distinguishes QoS levels, retained messages, and persistent sessions, noting that QoS only guarantees delivery across a single hop and that persistent sessions are the closest equivalent to queuing. The author demonstrates how to configure a Mosquitto broker and a paho-mqtt client with fixed client IDs, non-clean sessions, and session expiry intervals so that messages are buffered while a consumer is offline. Because QoS 1 provides at-least-once delivery, the consumer must also handle duplicate messages, for example by tracking sequence numbers.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in