A server can directly subscribe to all types of messages under a product, including Device Upstream Notification, Device Status Change Notification, Gateway's Sub-devices Discovery Reporting, Device Changes Throughout Lifecycle, Device Topological Relation Changes, TSL Historical Data Reporting and Firmware Update Status Notification. After you configure service subscription, IoT Platform forwards the subscribed messages from all devices under the product to your server.

Scenarios

Service subscription is ideal for scenarios in which device data is received in high concurrency.

The server receives subscribed data from all devices under the product.

If you have multiple servers that consume messages from the same product, the messages are randomly forwarded to one of the servers.

For information about and a comparison between scenarios of service subscription-based and rules engine-based data forwarding, see Compare data forwarding solutions.

Use the AMQP server to subscribe to device messages

AMQP refers to Advanced Message Queuing Protocol. After you configure AMQP service subscription, IoT Platform pushes all subscribed messages to your server through AMQP channels.

The following figure shows message forwarding for AMQP service subscription.

Service subscription

Benefits of AMQP service subscription:

  • Supports multiple consumer groups. With the same account, consumer group A can subscribe to product A messages in the development environment and consumer group B can subscribe to product B messages in the formal environment.
  • Facilitates troubleshooting. Service subscription allows you to view the client status, message accumulation, and message consumption rate.
  • Supports linear scalability. The push capability can be easily and linearly expanded if there are enough clients, indicating sufficient consumer capabilities.
  • Preferentially pushes real-time messages. Accumulated messages do not affect services.

    Real-time messages take precedence over accumulated messages due to push rate limits and push failures.

    Even if messages are accumulated due to failures or low consumption by the consumer client, messages generated by devices in real time are sent with accumulated messages after the client recovers. This ensures that the device preferentially returns to the available state.

Before using AMQP service subscription, you must configure it in the console. For more information, see Configure AMQP service subscription in the console. Then, develop an AMQP client to connect to IoT Platform and receive messages. For more information, see the following topics:

Limits

AMQP client access instructions

Java SDK access example

Node.js SDK access example

.NET SDK access example

Python SDK access example

Note IoT Platform calculates fees based on the number of pushed messages. For information about billing methods, see Messaging fees.

Use the MNS server to subscribe to device messages

IoT Platform pushes subscribed messages to Message Service (MNS) queues. Your applications listen to MNS queues to receive device messages.

The following figure shows message forwarding for MNS service subscription.

IoT service subscription

For information about how to use MNS to subscribe to device messages, see Use Message Service to subscribe to device messages.

Note MNS calculates fees for receiving messages pushed by IoT Platform. For more information about how MNS calculates fees and how to use MNS, see Message Service documentation.