You can use the data forwarding feature of the rules engine to forward data to a Message Service (MNS) topic. A service subscribes to the messages of the topic. This implements high-performance message transmission between the server and devices in a closed loop.
Prerequisites
- An MNS topic is created. A subscription whose push type is HTTP or queue is created for the topic. For more information about how to use MNS, see the MNS documentation.
- A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure data forwarding rules.
Data forwarding procedure
- A device sends data to a server.
The device publishes messages to IoT Platform. IoT Platform uses the rules engine to process these messages and forward these messages to an MNS topic. Then, the server calls an MNS operation to subscribe to messages.
This method adopts MNS to ensure the availability of messages and prevents data loss when the server is unavailable. Meanwhile, when a large number of concurrent messages are processed, MNS allows you to balance the workloads of the server. This prevents the service unavailability issue that is caused by an abrupt increase in workload. You can integrate IoT Platform with MNS. This implements high-performance message transmission between the server and the device in a closed loop.
- The server sends data to the device.
The server calls an IoT Platform operation to publish messages to IoT Platform. Then, the device subscribes to the messages of IoT Platform.
The following figure shows the data forwarding procedure.
