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.
- 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.
- Log on to the IoT Platform console.
- In the left-side navigation pane, choose .
- Click View next to the required rule. The Data Forwarding Rule page appears.
- In the Data Forwarding section, click Add Operation.
- In the Add Operation dialog box, select Send Data to MNS in the Select Operation field. Set the required parameters as prompted and click OK.
Parameter Description Select Operation Select Send Data to MNS. Region Select a region where MNS runs. Topic Select an MNS topic that is used to receive data.
MNS sends received messages to a subscription of the topic. The push type of the subscription is HTTP or queue. IoT Platform can push messages to MNS. You can subscribe to these messages through only the HTTP or queue method.
To create an MNS topic and subscription in the MNS console, click Create Topic. For more information, see the MNS documentation.
Role Authorize IoT Platform to write data to MNS.
- Go to the Data Forwarding page, find the required rule, and then click Start in the Actions column of the rule.