You can use the data forwarding feature to perform complex or fine-grained processing on device data if the message volume for all or specified devices under a single product is less than 1,000 queries per second (QPS). This feature forwards data from IoT Platform to Simple Message Queue (formerly MNS) (SMQ). Your application server can then subscribe to messages from the SMQ topic. This process establishes a high-performance, closed-loop message transmission path between devices and the server-side. This topic describes how to forward data to a data destination.
How it works
The data forwarding feature forwards messages from specified topics of all or specific devices under the same product to an SMQ queue in real time. Your application server calls the SMQ API to subscribe to the messages.
In the preceding figure:
Data source: For information about the supported topic categories, see Data format.
SQL expression: You can write an SQL expression to parse and process the JSON data reported by devices. For more information about the SQL syntax, see SQL expressions.
NoteData in binary format is passed through without being parsed.
Data destination: The SMQ topic that you create to receive device data. All messages sent to this topic are pushed to the SMQ queue that subscribes to it.
Advantages
Simple Message Queue (formerly MNS) ensures message reliability and prevents message loss if your application server becomes unavailable. It also provides peak-load shifting to handle large numbers of concurrent messages, which ensures that your application server remains available during sudden traffic spikes. The combination of IoT Platform and SMQ enables high-performance, closed-loop message transmission between devices and your application server.
Limits
IoT Platform instances in specific regions support forwarding data to Message Service (MNS). For more information about the supported regions, see Features by region.
Both the new and old versions of the data forwarding feature support forwarding data to Message Service (MNS). For an example of how to use the new version, see Forward data to Message Service (New).
The old version of the data forwarding feature is not supported for cloud gateway products, devices under cloud gateway products, or products and devices under MQTT-based instances. To forward data from these products and devices, you must use the new version of the data forwarding feature. For more information, see Data forwarding (New).
For information about other limits on forwarding device messages from an IoT Platform instance, see Limits.
Prerequisites
You have created a data forwarding rule and written an SQL expression to process data. For more information, see Set a data forwarding rule.
You have created an SMQ topic and created an HTTP or queue subscription for this topic. For more information about how to use SMQ, see the Simple Message Queue (SMQ) documentation.
ImportantFor an Enterprise instance, the SMQ topic must be in the same region as the instance.
Your application server uses the SMQ server-side software development kit (SDK) to listen to the MNS queue that subscribes to the SMQ topic. This allows your SMQ cloud application to receive device messages from IoT Platform.
For more information about how to call the SMQ server-side SDK, see the Topic User Guide for the corresponding SDK in SDK download and usage.
Configure a data forwarding 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 navigation pane on the left, choose .
Find the rule that you want to manage and click View in the Actions column. The Data Forwarding Rule page appears.
ImportantIf the new version of the data forwarding page is displayed, click Back to Old Version in the upper-right corner. Then, find the destination rule and click View.
In the Forward Data section, click Add Operation.
In the Add Operation dialog box, select Send Data To Message Service (MNS) as the operation. Then, follow the on-screen instructions to configure the other parameters and click Confirm.
Parameter
Description
Select an operation.
Select Forward data to Message Service (MNS).
Region
Select the region where Message Service is activated.
Topic
Select the SMQ topic that you want to use to receive data.
SMQ forwards the received messages to the HTTP and queue subscriptions under this topic. Currently, you can subscribe to messages that IoT Platform pushes to an SMQ topic only using the HTTP or queue method.
You can click Create Topic to go to the Simple Message Queue (formerly MNS) console to create an SMQ topic and a subscription. For more information, see the Simple Message Queue (SMQ) documentation.
Role
Grant IoT Platform the permissions to write data to Simple Message Queue (formerly MNS).
If you have not created the required RAM role, click Create RAM Role to go to the RAM console. Then, create a RAM role and an authorization policy. For more information, see Create a RAM role.
Return to the Data Forwarding page. Find the rule and click Start to enable the rule.
What to do next
You can view the operational logs for device-to-cloud messages and data forwarding on the IoT Platform Logs tab. To go to this tab, go to the IoT Platform console, find your instance, and choose . For more information, see IoT Platform logs.
You can log on to the Simple Message Queue (formerly MNS) console to view the messages that are pushed from the MNS topic to the queue. For more information, see Receive messages.
References
For instructions on how to connect a device to IoT Platform to report data, see Device connection guide.
You can view the available resources for message forwarding Transaction Per Second (TPS) on the instance details page. This helps ensure that device messages can be forwarded to Simple Message Queue (formerly MNS) for consumption. For more information, see View instance information and operational data. If the available resources are insufficient, you can upgrade the instance. For more information, see Upgrade an instance.
You can view the metrics of the Simple Message Queue (formerly MNS) topic to check the number of received messages. For more information, see View topic metrics.
You can use the Log Management feature to push the operation logs of message topics to Simple Log Service. If an exception occurs when a message is consumed, you can query the message trace and other information using the MessageId to diagnose the exception. For more information, see Push logs to Simple Log Service and View logs in Simple Log Service.