Forward data to ApsaraMQ for RocketMQ

更新时间:
复制 MD 格式

When the message rate between devices and IoT Platform exceeds 1,000 QPS, use data forwarding to send device data to ApsaraMQ for RocketMQ for reliable end-to-end message transmission and server-side consumption.

How it works

image

Data forwarding delivers device messages to an ApsaraMQ for RocketMQ client for consumption.

  1. Application server: Register a consumer by using the ApsaraMQ for RocketMQ SDK to receive messages.

  2. IoT Platform: Configure data forwarding to route device messages to ApsaraMQ for RocketMQ.

    • Data source topic: Supported topic categories are listed in Data format.

    • SQL expression: Write an SQL expression to parse and process JSON data from devices. SQL expressions.

      Note

      Data in binary format is passed through without being parsed.

    • Data destination: The ApsaraMQ for RocketMQ topic that receives device messages. Create the topic in the ApsaraMQ for RocketMQ console beforehand. Create a topic.

      You can tag device messages for consumer-side filtering.

  3. ApsaraMQ for RocketMQ: When a consumer retrieves messages, ApsaraMQ for RocketMQ performs server-side filtering and delivers only matching messages to the application server.

Limits

  • Data forwarding to ApsaraMQ for RocketMQ is available only in specific regions. Features by region.

  • The ApsaraMQ for RocketMQ instance must be in the same region as the IoT Platform instance. Existing cross-region configurations are not affected and continue to function as expected.

  • You can forward data only to topics in ApsaraMQ for RocketMQ 4.x or 5.x series instances. Serverless instances are not supported. For topics in ApsaraMQ for RocketMQ 5.x instances, the Message Type must be Normal Message.

  • Both the new and previous versions of data forwarding support ApsaraMQ for RocketMQ. Forward data to ApsaraMQ for RocketMQ (new version).

  • The previous version of data forwarding does not support products and devices managed by cloud gateway products or that use MQTT-based instances. Use Data forwarding (new version) for these products and devices.

Prerequisites

Automatic configurations for RocketMQ 5.0

When you use ApsaraMQ for RocketMQ 5.0, the following configurations are completed automatically after you set the data destination:

  • IoT Platform occupies two IP addresses from the vSwitch of the ApsaraMQ for RocketMQ instance.

  • A managed security group (name prefixed with sg-nsm-) is created in the VPC of the ApsaraMQ for RocketMQ instance.

Configure a data destination

  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 ID or instance name.

  3. In the left-side navigation pane, choose Message Forwarding > Data Forwarding.

  4. Click View next to the target rule. The Data Forwarding Rule page appears.

    Important

    If the Data Forwarding (New Version) page is displayed, click Back to Previous Version in the upper-right corner, then click View next to the target rule.

  5. In the Forward Data section, click Add Operation.

  6. In the Add Operation dialog box, select Forward data to ApsaraMQ for RocketMQ. Set the other parameters as prompted and click OK.

    Parameter

    Description

    Select an operation

    Select Forward data to ApsaraMQ for RocketMQ.

    Region

    Select the region of the ApsaraMQ for RocketMQ instance.

    Instance

    Select an ApsaraMQ for RocketMQ instance.

    Click Create Instance to create one in the ApsaraMQ for RocketMQ console. ApsaraMQ for RocketMQ documentation.

    Topic

    Select the ApsaraMQ for RocketMQ topic to receive data from IoT Platform.

    Click Create Topic to create one in the ApsaraMQ for RocketMQ console.

    Tag

    (Optional) Set a tag.

    All messages forwarded by this operation carry the tag, which consumers can use for filtering.

    Maximum length: 128 bytes. Supports constants or variables in ${key} format, where key maps to a field in the SQL-processed JSON data.

    Authorization

    Grant IoT Platform write access to ApsaraMQ for RocketMQ.

    If no RAM role exists, click Create RAM Role to create a RAM role and authorization policy in the RAM console. Create a RAM role.

  7. On the Data Forwarding page, find the rule and click Start in the Actions column.

  8. Test

    Publish a message to the topic defined in the rule's SQL statement, then check the forwarding logs.

View forwarding logs

  1. In the IoT Platform console, click the target Enterprise instance to view the device status and message forwarding logs. For more information, see IoT Platform logs.

  2. In the terminal on the application server that is subscribed to ApsaraMQ for RocketMQ resources, view the logs for message subscription and consumption.

  3. In the ApsaraMQ for RocketMQ console, on the Instance Details page, view the content and trace of the messages received by the consumer. For more information, see Query message traces.

References

Consume device messages using an ApsaraMQ for RocketMQ client

FAQ