Persistent messaging
Overview
Within MQTT 5, clients can set a unique Message Expiry Interval in seconds for each PUBLISH message. This interval establishes the duration the broker preserves the PUBLISH message for subscribers that match the topic but are currently offline. If the interval isn’t defined, the broker must indefinitely hold the message for matching subscribers, yet disconnected subscribers. Furthermore, if the ‘retained=true’ option is selected during the PUBLISH message, the interval also dictates the length of time a message is retained on a particular topic, reference HiveMQ.
Example
This example uses the MQTT v5 capabilities to store published messages on the MQTT broker.
Message persistence attributes schema
message expiry interval
The maximum time in seconds the broker will hold the message for matching subscribers, who may be offline (see Session Management)
Long
Default: 0 seconds
retain
If message is retained on the broker
Boolean
Default: true
Last updated
Was this helpful?