You can use the data forwarding feature of the rules engine to forward data to a Simple Message Queue (formerly MNS) (SMQ) topic. A server subscribes to messages of the topic. This way, high-performance message transmission is implemented between the server and devices.
Prerequisites
An IoT Platform instance whose data can be forwarded to MNS is created in a region that supports data forwarding to MNS. For more information, see Regions.
An MNS topic is created. A subscription whose Push Type parameter is set to HTTP or Queue is created for the topic. For more information, see the MNS documentation.
ImportantIf you use an IoT Platform instance of the Enterprise Edition, the region where the MNS topic resides must be the same as that of the IoT Platform instance.
A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure a data forwarding rule.
Usage notes
You can use the new version or old version of the data forwarding feature to forward data to MNS. For more information about how to use the new version of the data forwarding feature, see Use the new version of the data forwarding feature to forward data to MNS.
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. The server then calls an MNS operation to subscribe to messages in the topic.
MNS is used to ensure the availability of messages. This prevents data loss when the server is unavailable. In addition, when a large number of concurrent messages are processed, MNS allows you to balance the workloads of the server. This prevents service unavailability that is caused by an abrupt increase in workloads. IoT Platform and MNS are used together to implement high-performance message transmission between the server and the device.
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.
Procedure
- Log on to the IoT Platform console.
On the Overview page, click All environment. On the All environment tab, find the instance that you want to manage and click the instance ID or instance name.
- In the left-side navigation pane, choose .
- Click View next to the rule that you want to manage. The Data Forwarding Rule page appears. Important If the new version of the Data Forwarding page is displayed, click Back to Previous Version in the upper-right corner, and then click View in the Actions column of the rule that you want to manage.
- In the Forward Data section, click Add Operation.
In the Add Operation dialog box, select Send Data to MNS from the Operation drop-down list. Set the parameters and click OK.
Parameter
Description
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 parameter value of the subscription is HTTP or Queue. You can subscribe to messages that IoT Platform pushes to MNS 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.
If you do not have Resource Access Management (RAM) roles, click Create RAM Role to go to the RAM console, create a RAM role, and then grant permissions to the role. For more information, see Create a RAM role.
- Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.