Skip to content
Protocols

Retained message

An MQTT message that the broker stores for its topic and delivers immediately to any new subscriber, so late joiners get the last known value.

Normally an MQTT broker forwards a message to current subscribers and forgets it. When a publisher sets the retain flag, the broker keeps that message as the last value for the topic and sends it the moment a client subscribes, before any live traffic. A dashboard that connects an hour after a sensor’s last report still sees its latest reading.

Retained messages suit slowly changing state: a device’s online status, its configuration, the current setpoint of a thermostat. They are a poor fit for high-frequency telemetry, where only the most recent sample survives anyway, and they can mislead if stale values are not cleared, which is done by publishing an empty retained message. They are often combined with a last will message so that a crashed device’s status flips to offline automatically. See MQTT explained.

Part of the IoT Glossary. Spotted an error or a missing term? Tell us.