Forward data to ApsaraMQ for RocketMQ
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
Data forwarding delivers device messages to an ApsaraMQ for RocketMQ client for consumption.
-
Application server: Register a consumer by using the ApsaraMQ for RocketMQ SDK to receive messages.
-
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.
NoteData 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.
-
-
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
-
An ApsaraMQ for RocketMQ instance and a topic are created to receive data. ApsaraMQ for RocketMQ Quick Start.
-
A data forwarding rule is created with an SQL statement for data processing. Configure a data forwarding rule.
-
The ApsaraMQ for RocketMQ SDK is integrated in your application server to consume messages. Call the SDK to consume messages.
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
-
Log on to the IoT Platform console.
On the Overview page, find the instance that you want to manage and click the instance ID or instance name.
-
In the left-side navigation pane, choose .
-
Click View next to the target rule. The Data Forwarding Rule page appears.
ImportantIf 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.
-
In the Forward Data section, click Add Operation.
-
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.
-
On the Data Forwarding page, find the rule and click Start in the Actions column.
-
Test
Publish a message to the topic defined in the rule's SQL statement, then check the forwarding logs.
View forwarding logs
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.
In the terminal on the application server that is subscribed to ApsaraMQ for RocketMQ resources, view the logs for message subscription and consumption.
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