IoT Platform allows you to use a consumer group to subscribe to the messages of a topic and forward the messages to an Advanced Message Queuing Protocol (AMQP) server. This topic describes how to configure and manage an AMQP server-side subscription in the IoT Platform console.
Prerequisites
A consumer group is created. The consumer group is used to subscribe to the messages of topics. You can use the default consumer group (DEFAULT_GROUP) or create a consumer group in IoT Platform. For more information, see Manage consumer groups.
Configure a subscription
To specify the type of messages to which you want to subscribe, perform the following steps:
Log on to the IoT Platform console.
On the Overview page, click All environment. On the All environment tab, find the instance that you want to manage and click the instance ID or instance name.
In the left-side navigation pane, choose .
On the Server-side Subscription page, click Create Subscription.
In the Create Subscription dialog box, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Products
Select the product to which the devices belong. The messages that are submitted by the devices are pushed to consumers.
Subscription Type
Select AMQP.
Consumer Group
Select consumer groups. You can specify multiple consumer groups for a product and create multiple subscriptions for multiple products in a consumer group.
IoT Platform provides a default consumer group to consume messages. If you want to group consumers, perform the following steps to create a consumer group: In the lower-right corner of the Select Consumer Groups dialog box, click Create Consumer Group and configure the parameters as prompted. For more information, see Manage consumer groups.
Message Type
Select the types of messages. You can subscribe to the following types of device messages. For more information about basic communication topics, message forwarding topics, and related data formats, see Data formats.
ImportantIf you use cloud gateway products and devices, IoT Platform pushes only Device Upstream Notification, Device Status Change Notification, and Device Changes Throughout Lifecycle messages to the products and devices. For more information about message forwarding topics and data formats, see Messaging over open source MQTT, Messaging over JT/T 808, and Messaging over GB/T 32960.
Device Upstream Notification: the messages in topics whose Allowed Operations parameter is set to Publish. For more information, see Topics.
The messages include custom data and Thing Specification Language (TSL) data that is submitted by devices. The upstream TSL data includes property data, event data, responses to property setting requests, and responses to service calls. The TSL data that is pushed to user servers is processed by IoT Platform. For more information, see Data formats.
For example, the following topic categories are defined for a product:
/${YourProductKey}/${YourDeviceName}/user/get
. The Allowed Operations parameter of this topic category is set to Subscribe./${YourProductKey}/${YourDeviceName}/user/update
. The Allowed Operations parameter of this topic category is set to Publish./${YourProductKey}/${YourDeviceName}/thing/event/property/post
. The Allowed Operations parameter of this topic category is set to Publish.
The server-side subscription feature pushes the messages of the following topic categories:
/${YourProductKey}/${YourDeviceName}/user/update
and/${YourProductKey}/${YourDeviceName}/thing/event/property/post
.ImportantIf you want to subscribe to the response data of asynchronous service calls, make sure that the message ID that is returned by the device is the same as the message ID that is generated when IoT Platform sends downstream data.
Device Status Change Notification: the notifications that are sent by devices when the devices go online or offline.
Gateway's sub-devices discovery report: the sub-device data that gateways submit when the gateways detect new sub-devices. The gateways must have applications that can be used to detect sub-devices. This message type is specific to gateways.
Device Topological Relation Changes: the notifications that gateways send when topological relationships between sub-devices and the gateways are created or deleted. This message type is specific to gateways.
Device Changes Throughout Lifecycle: the notifications that devices send when the devices are created, deleted, enabled, or disabled.
TSL Historical Data Reporting: the historical properties and events that are submitted by devices.
OTA Update Status Notification: the notifications that are sent by devices during firmware verification and batch update. When a device update task is successful, fails, is canceled, or is being performed, a notification is pushed.
Device tag change: the messages that are sent by devices when device tags are changed.
Submit a module version number: the messages that are sent by devices when over-the-air (OTA) module versions are changed.
Batch status notification: the notifications that are sent by devices when the status of OTA update batches is changed.
NoteWhen you listen to device messages, you may need to filter or process the messages. In this case, you can forward messages to an AMQP consumer group by using data forwarding rules. Then, you can receive the messages by using the AMQP client. For more information, see Data forwarding.
For more information about how to forward messages to an AMQP server and the device topics to which you can subscribe, see Data formats.
Manage the subscriptions of a product
After you configure a subscription, go to the Server-side Subscription page and find the product for which the subscription is created. You can perform multiple operations on the subscription. The following table describes the operations.
Operation | Procedure |
Edit | You can change the consumer group and message type.
|
Delete | Warning If the device data to which you subscribed for the product is used in other applications, your services may become unavailable or your business may be affected. Proceed with caution.
|
What to do next
Configure an AMQP client: We recommend that you use the AMQP SDK provided by IoT Platform. Alibaba Cloud does not provide technical support for user-developed AMQP SDKs.
After the configurations are complete and the submitted device data is received by an AMQP client, perform the following steps to view logs in the IoT Platform console: Choose
. The Cloud run log tab displays the log entries that are generated when a device submits data, IoT Platform forwards the data to the AMQP client, and the AMQP client returns an ACK message.