You can use the rules engine to forward data from IoT Platform to Message Queue for Apache RocketMQ. This ensures reliable end-to-end transmission from devices, IoT Platform, and Message Queue for Apache RocketMQ to application servers.

Prerequisites

  • An IoT Platform instance whose data can be forwarded to Message Queue for Apache RocketMQ is created in a region that supports data forwarding to Message Queue for Apache RocketMQ.
    Supported instancesSupported regions
    Enterprise Edition instances
    • China (Shanghai)
    • Japan (Tokyo)
    Public instances
    • China (Shanghai)
    • Singapore
  • A Message Queue for Apache RocketMQ instance and a topic that can be used to receive data are created. For more information, see Get started with Message Queue for Apache RocketMQ.
    Important
    • The Message Queue for Apache RocketMQ instance must reside in the same region as the IoT Platform instance for which you want to configure a data forwarding rule. This limit does not apply to the existing data forwarding rules that are used to forward data across instances in different regions.
    • You can forward data streams to only the topics of Message Queue for Apache RocketMQ V4.x.
  • 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 Message Queue for Apache RocketMQ. 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 Message Queue for Apache RocketMQ.

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 Message Forwarding > 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 to RocketMQ from the Select Operation drop-down list. Configure the parameters as prompted and click OK. The following table describes the parameters.
    ParameterDescription
    OperationSelect Send Data to Message Queue for Apache RocketMQ.
    RegionSelect the region where the Message Queue for Apache RocketMQ instance resides.
    InstanceSelect the Message Queue for Apache RocketMQ instance.

    You can click Create Instance to go to the Message Queue for Apache RocketMQ console and create a Message Queue for Apache RocketMQ instance. For more information, see the Message Queue for Apache RocketMQ documentation.

    TopicSelect the Message Queue for Apache RocketMQ topic that you want to use to receive data from IoT Platform.

    You can click Create Topic to go to the Message Queue for Apache RocketMQ console and create a Message Queue for Apache RocketMQ topic.

    TagOptional. Specify a tag.

    If you specify a tag, the tag is attached to all messages that are forwarded to the Message Queue for Apache RocketMQ topic. You can filter messages by tag on your consumer client.

    The maximum length of a tag is 128 bytes. You can enter a constant or a variable. Specify variables in the ${key} format. ${key} specifies that the variable references the value of a key in the JSON result of an SQL statement.

    Grant permissionsGrant IoT Platform the permissions to write data to Message Queue for Apache RocketMQ.

    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.
  8. Perform a test.

    Publish a message to the topic defined in the SQL statement that is configured in the data forwarding rule. Then, go to the Message Queue for Apache RocketMQ console to check whether the message is received.

Example

Forward device data to business servers by using Message Queue for Apache RocketMQ