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 data forwarding rules.
  • 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. In the left-side navigation pane, choose Rules > Data Forwarding.
  3. Click View next to the required rule. The Data Forwarding Rule page appears.
  4. In the Data Forwarding section, click Add Operation.
  5. 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.
  6. Go to the Data Forwarding page, find the required rule, 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: