Updated on 2023-10-18 GMT+08:00

Message Delivery Overview

Introduction

Message delivery does not rely on product models. The platform provides one-way notifications for devices and caches messages. It delivers messages from the cloud to devices in asynchronous mode (without waiting for responses from devices). If a device is offline, data is sent after the device is online. The maximum cache duration is 24 hours. By default, the platform stores a maximum of 20 messages for each device. If the number of messages exceeds 20, subsequent messages will replace the earliest messages. In addition, messages can be delivered in the format of custom topics.

Table 1 Message delivery topic type

Topic Type

Description

System topic

The platform predefines topics for communications with devices. For details of the topic list and functions, see Topics.

Custom topic

Devices and the platform can communicate based on custom topics.

Types of custom topics:

  • Topics defined in the product are prefixed with $oc/devices/{device_id}/user/. During message reporting or delivery, the platform checks whether the topic is defined in the product. Undefined topics will be rejected by the platform. For details about how to use this type of topics, see Using a Custom Topic for Communication.
  • Custom topics that do not start with $oc, for example, /aircondition/data/up, are used for message communications. The platform does not check the topic permission. This type of topics enables upstream and downstream message communications based on MQTT rules. For details, see Migrating a Custom Topic to the Cloud.

Scenarios

  • The data format needs to be customized and does not rely on the product model.
  • A large amount of data is frequently delivered.

Constraints

  • Maximum size of a single message: 256 KB.
  • A maximum of 20 messages can be cached for a single device.
  • Maximum length of a custom MQTT topic: 128 bytes.
  • The cache duration is configurable and cannot exceed 24 hours.

Quality of Service

  • IoTDA supports MQTT QoS 0 and QoS 1, but does not support QoS 2.
  • If the QoS of a topic is 0, the message is delivered only once without waiting for the device to return an ACK message. If the QoS of a topic is 1, the message delivery is successful only after the device returns an ACK message.
  • Devices subscribe to the system topic whose QoS is 0 by default. If the downstream system topic whose QoS is 1 is required, devices need to be configured to subscribe to the topic.
  • If a device needs to subscribe to a custom topic that does not start with $oc and the QoS is 1, submit a service ticket.
  • If the QoS of the subscribed topic is 1 and the platform does not receive an ACK message from the device, the platform resends the message every 2 seconds for three times by default.

    If the device still does not return an acknowledgment response and the message is still cached, the platform resends the message when the device goes online again or subscribes to a topic. By default, the platform resends the message every 10 seconds for five times.

    In addition, the mechanism of resending every 2 seconds is triggered. Therefore, the device may receive duplicate messages. It is recommended that devices have deduplication mechanisms.