MQTT - QoS and Message Retention
The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message
TagoIO officially supports QoS 0 and 1.
When a QoS 1 message is sent to the device, - from TagoIO Analysis or others - it expects to receive a puback with the messageId of the message. If not, the device will receive the message again when a new connection with the MQTT broker has been established.
Tago MQTT broker can retain the last message to each topic if the client chooses to do so, and every time any client subscribes to that same topic it will receive the retained message.
Retaining a message
Retaining a message to any topic using Mqttfx is very simple, just set the retained flag and publish the message with some payload. In the example below we sent a retained message to the topic
home/temperature with the payload ‘22’.
Now every time some client subscribes to the topic
home/temperature or uses wildcards that match that topic, it will receive the message 22 immediately after the subscription.
Tago MQTT broker only stores the last retained message per topic, meaning that if the client sends another message to the topic
home/temperature, it will overwrite the previous retained message.
Deleting a retained message
If the user no longer wishes to have the retained message on a specific topic, this message can be easily deleted from the broker.
To delete a message, just publish to the topic you wish with the retained flag and no payload. In this example, we will delete the retained message on the topic