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

Usage notes

  • After a ApsaraMQ 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 ApsaraMQ 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 ApsaraMQ for MQTT client times out. Therefore, if the ApsaraMQ 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, ApsaraMQ 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 levelcleanSession=truecleanSession=false
QoS0Offline 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.
QoS1Offline 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.
QoS2Offline messages are not delivered. Online messages are delivered only once. Not supported
For more information about the QoS and cleanSession parameters, see Terms.