To simplify the mechanism used to receive offline messages, Message Queue for MQTT automatically loads offline messages and delivers them to a Message Queue for MQTT client after the client establishes a connection to the Message Queue for MQTT broker and passes permission verification.

Usage notes

  • After a Message Queue for MQTT client establishes a connection to the broker, the client must pass the permission verification to enable the automatic loading of offline messages. For example, if a Message Queue for MQTT client adopts the token-based verification mode, you must upload a token and the client must pass the verification before it can receive offline messages.
  • An offline message takes a specific amount of time to generate. This is because the pushed message can be determined as an offline message only after the acknowledgment of the Message Queue for MQTT client times out. Therefore, if the Message Queue for MQTT client experiences transient disconnection and reconnection, the client may not be able to immediately receive the latest offline message. The latency is generally 5 to 10 seconds.
  • If the number of offline messages exceeds 30, Message Queue for MQTT sends offline messages in batches. Each batch contains 30 messages. Batches are sent at intervals of 5 seconds.
Note The automatic loading mechanism allows you to receive offline messages without the need to pull the messages. The mechanism takes effect even if you still use the message pulling method to receive offline messages.

Configuration

You can set the QoS and cleanSession parameters in a consumer to determine whether the consumer can receive offline messages.
Table 1. Combinations of QoS levels and the cleanSession parameter
QoS level cleanSession=true cleanSession=false
QoS0 Offline messages are not delivered. Only one delivery attempt is made for online messages. Offline messages are not delivered. Only one delivery attempt is made for online messages.
QoS1 Offline messages are not delivered. Online messages are guaranteed to reach the intended Message Queue for MQTT clients. Offline messages are delivered. Both offline and online messages are guaranteed to reach the intended Message Queue for MQTT clients.
QoS2 Offline messages are not delivered. Online messages are delivered once. Not supported.
For more information about the QoS and cleanSession parameters, see Terms.