You can use the data forwarding feature of the rules engine to forward data to a Message Service (MNS) topic. A server subscribes to messages of the topic. This way, high-performance message transmission is implemented between the server and devices.

Prerequisites

  • 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.
    Notice If 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.

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.

Data forwarding between servers and devices

Procedure

  1. Log on to the IoT Platform console.
  2. On the Overview page, find the instance and click the instance name to go to the Instance Details page.
    Notice Enterprise Edition instances are available only in the China (shanghai) and Japan (Tokyo) region. If your IoT Platform is not activated in the China (shanghai) or Japan (Tokyo) region, skip this step.
    Overview
  3. In the left-side navigation pane, choose Rules Engine > Data Forwarding.
  4. Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
    Notice If the new version of the Data Forwarding page is displayed, you must click Back to Previous Version in the upper-right corner, and then click View in the Actions column corresponding to the rule that you want to manage.
  5. In the Forward Data section, click Add Operation.
  6. 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 no RAM roles exist, click Create RAM Role to go to the Resource Access Management (RAM) console, create a RAM role, and then grant permissions to the RAM role. For more information, see Create a RAM role.

  7. Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.