You can use the rules engine to forward messages that are sent by devices to IoT Platform. These messages can be processed by using SQL statements, forwarded to Advanced Message Queuing Protocol (AMQP) consumer groups, and then consumed by AMQP clients.

Prerequisites

  • 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.
  • An AMQP consumer group is created and used as the data forwarding destination. For more information about how to create and manage consumer groups, see Manage consumer groups.

Procedure

  1. Log on to the IoT Platform console.
  2. On the Overview page, find the instance and click the instance name to go to the Instance Details page.
    Notice Enterprise Edition instances are available only in the China (shanghai) and Japan (Tokyo) region. If your IoT Platform is not activated in the China (shanghai) or Japan (Tokyo) region, skip this step.
    Overview
  3. In the left-side navigation pane, choose Rules Engine > Data Forwarding.
  4. Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
    Notice If the new version of the Data Forwarding page is displayed, you must click Back to Previous Version in the upper-right corner, and then click View in the Actions column corresponding to the rule that you want to manage.
  5. In the Forward Data section, click Add Operation.
  6. In the Add Operation dialog box, select Publish to AMQP Subscribed Consumer Group. Set the required parameters as prompted and click OK.
    Add Operation
    Parameter Description
    Select Operation Select Publish to AMQP Subscribed Consumer Group.
    Consumer Group Select an existing consumer group as the data forwarding destination. Click Create Consumer Group to create a consumer group.
    Tag If you set a tag, the tag will be added to all messages that are forwarded by this operation to the AMQP consumer group.
    The tag must be 1 to 128 characters in length. You can specify a constant or a variable.
    • A constant can contain letters and digits.
    • If you specify a variable, use the format of ${key}. ${key} indicates that the variable references the value of a key in the JSON result of an SQL statement. If the value is unavailable, a tag is not added to the messages.
  7. Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.

Configure an AMQP client to consume messages

After the data is forwarded to the AMQP consumer group, your server consumes the messages by using the AMQP client. For more information about how to configure an AMQP client, see Connect an AMQP client to IoT Platform.

For sample code of the AMQP client implementation, see the following topics: