To simplify the offline message retrieving mechanism, Message Queue for MQTT automatically loads offline messages and delivers them to an MQTT client after the MQTT client successfully establishes a connection and passes permission verification.
You must note the following:
After the MQTT client establishes a connection, it must pass the permission verification to automatically load offline messages. For example, if you use token verification for an MQTT client, you must upload the token and the MQTT client must pass the verification before it can receive offline messages.
An offline message takes some time to generate, because the pushed message can be judged as an offline message after the MQTT client acknowledgement times out. Therefore, if the MQTT client experiences transient disconnection and reconnection, you may not be able to obtain the offline notification message immediately. The latency is generally 5 to 10 seconds.
If you have too many offline messages, that is, more than 30 messages, Message Queue for MQTT sends offline messages in batches (30 messages a batch every 5 seconds).
The automatic loading mechanism allows you to replace the original active pulling method for retrieving offline messages, though you can still use the original method.
You need to set the QoS and cleanSession parameters to retrieve offline messages. For details, see Terms.