All Products
Search
Document Center

IoT Platform:Forward data to ApsaraMQ for RocketMQ

Last Updated:Nov 03, 2023

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

Prerequisites

  • An IoT Platform instance whose data can be forwarded to ApsaraMQ for RocketMQ is created in a region that supports data forwarding to ApsaraMQ for RocketMQ. For more information about the regions that support data forwarding to ApsaraMQ for RocketMQ, see Regions.

  • An ApsaraMQ for RocketMQ instance and a topic that can be used to receive data are created. For more information, see Get started with ApsaraMQ for RocketMQ.

    Important
    • The ApsaraMQ for 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 existing data forwarding rules that are used to forward data across instances in different regions.

    • You can forward data to a topic of only an ApsaraMQ for RocketMQ V4.x instance or V5.x 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.

Precaution

  • You can use the new version or previous version of the data forwarding feature to forward data to ApsaraMQ for 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 ApsaraMQ for RocketMQ.

  • If you specify Send Data to ApsaraMQ for RocketMQ when you configure a data destination, the following settings are automatically configured. After the configuration is complete, you can forward device data to your ApsaraMQ for RocketMQ V5.0 instance by using the rules engine of IoT Platform.

    • Two IP addresses of the vSwitch to which the ApsaraMQ for RocketMQ instance is connected are assigned to IoT Platform.

    • A managed security group is created in the virtual private cloud (VPC) in which the ApsaraMQ for RocketMQ instance resides. By default, the name of the security group starts with sg-nsm-.

Procedure

  1. Log on to the IoT Platform console.
  2. 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.

  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 Data to ApsaraMQ for Apache RocketMQ from the Operation drop-down list. Configure other parameters as prompted and click OK. The following table describes the parameters.

    Parameter

    Description

    Operation

    Select Send Data to ApsaraMQ for RocketMQ.

    Region

    Select the region where the ApsaraMQ for RocketMQ instance resides.

    Instance

    Select the ApsaraMQ for RocketMQ instance.

    You can click Create Instance to go to the ApsaraMQ for RocketMQ console and create an ApsaraMQ for RocketMQ instance. For more information, see the ApsaraMQ for RocketMQ documentation.

    Topic

    Select the ApsaraMQ for RocketMQ topic that you want to use to receive data from IoT Platform.

    You can click Create Topic to go to the ApsaraMQ for RocketMQ console and create an ApsaraMQ for RocketMQ topic.

    Tag

    Optional. Specify a tag.

    If you specify a tag, the tag is attached to all messages that are forwarded to the ApsaraMQ for 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.

    Authorization

    Grant IoT Platform the permissions to write data to ApsaraMQ for RocketMQ.

    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.

  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 that is defined in the SQL statement that is configured in the data forwarding rule. Then, go to the ApsaraMQ for RocketMQ console to check whether the message is received.

Example

Forward device data to business servers by using ApsaraMQ for RocketMQ