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 IoT Platform instance whose data can be forwarded to MNS is created in a region that supports data forwarding to MNS.
    Supported instances Supported regions
    Enterprise Edition instances: Standard and Video
    • China (Shanghai)
    • Japan (Tokyo)
    Public instances
    • China (Shanghai)
    • Singapore
    • Japan (Tokyo)
    • Germany (Frankfurt)
    • US (Silicon Valley) and US (Virginia)
  • 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.
    Important 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.

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.

Data forwarding between servers and devices

Procedure

  1. Log on to the IoT Platform console.
  2. On the Overview page, find the instance that you want to manage and click the instance name to go to the Instance Details page.
    Important Enterprise Edition instances are available in the China (Shanghai) and Japan (Tokyo) regions. If the Enterprise Edition instances are unavailable in the region that you select, 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.
    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.
  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.