Forward data to ApsaraMQ for Kafka

更新时间:
复制 MD 格式

You can use the rule engine to forward data from IoT Platform to ApsaraMQ for Kafka for storage. This establishes a highly reliable data pipeline, ensuring end-to-end transmission from your devices to your application servers.

Limitations

  • serverless Kafka instances are not supported.

Prerequisites

  • An ApsaraMQ for Kafka instance and a topic to receive data are created. For more information, see Kafka Quick Start.

    Important

    The ApsaraMQ for Kafka instance must be in the same region as your IoT Platform instance.

  • Your Alibaba Cloud account is whitelisted to forward data to ApsaraMQ for Kafka.

  • A data forwarding rule and an SQL query for data processing are created. For more information, see Set up data forwarding rules.

Background information

After you configure the data destination, the rule engine automatically performs the following actions to forward device data from IoT Platform to ApsaraMQ for Kafka.

  • IoT Platform uses two IP addresses from the VSwitch where the ApsaraMQ for Kafka instance is located.

  • IoT Platform creates a managed security group in the VPC where the ApsaraMQ for Kafka instance is located. The security group name starts with sg-nsm- by default.

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

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

  4. Find the rule that you want to manage and click View in the Actions column. The Data Forwarding Rule page appears.

    Important

    If 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.

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

  6. In the Add Action dialog box, configure the parameters as prompted, and then click OK.

    Parameter

    Description

    Select action

    Select Forward data to ApsaraMQ for Kafka.

    Role

    Select a RAM role to authorize IoT Platform to write data to ApsaraMQ for Kafka.

    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.

    Region

    This parameter is fixed to the region where your IoT Platform instance is located.

    Instance

    Select an ApsaraMQ for Kafka instance.

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

    Topic

    Select the Kafka topic that receives data from IoT Platform.

    You can click Create topic to go to the ApsaraMQ for Kafka console and create a topic. For more information, see Create a topic.

  7. Return to the Data Forwarding page. Find the rule and click Start to enable the rule.

  8. Publish a message to the topic defined in the rule's SQL query.

    You can use the device simulator for debugging. For more information, see Device simulator.

  9. In the ApsaraMQ for Kafka console, go to the Topic details page of your instance to query the forwarded message.

    Click the Query messages tab. Select a Query method, such as Query by time. Set the Partition and Time point, and then click Query. The results are displayed in a table that includes the Partition, Offset, Key, Value, Message creation time, and Actions column. You can click Download key and Download value to retrieve the message content.