Retained Messages

Publishers can mark any message they send as 'to be retained'. There can only be one retained message per topic, and any new 'retained' message by any publisher to that topic will replace the current one. Retained messages are only delivered when a client subscribes to a topic. The most common use case for this is to push some kind of last known message (or sensor value) to new subscribers. The broker has to store all retained messages in a database, as the retained message will not expire.

Retained messages are not to be confused with 'offline' messages, i.e. the QoS 1 and 2 messages that the broker has to store for any offline subscribers.

This feature paired with the LWT feature enable to implement a simple presence notification system using plain MQTT.