What is server-side subscription

更新时间:
复制 MD 格式

A server can directly subscribe to various types of messages for a product, including device-reported messages, device status notifications, device lifecycle changes, sub-device discovery reports from gateways, and device topology changes. After you configure a server-side subscription, IoT Platform forwards messages of the subscribed types from all devices under the product to your server.

Scenarios

Use a server-side subscription in the following scenarios:

  • A server only needs to receive device data, especially in high concurrency scenarios.

  • A server needs to receive subscription data from all devices that belong to a product.

Note

If multiple servers consume subscribed messages for the same product, messages are randomly forwarded to one of the servers.

For a comparison of the scenarios and features of server-side subscription and data forwarding using the rules engine, see Comparison of data forwarding solutions.

Subscribe to messages using an AMQP server-side subscription

After you configure an Advanced Message Queuing Protocol (AMQP) server-side subscription, IoT Platform pushes messages of all subscribed types for a product to your server through an AMQP channel.

The message flow for an AMQP server-side subscription is shown in the following figure.

image

Advantages of an AMQP server-side subscription:

  • Supports multiple consumer groups. For example, within the same account, consumer group A can subscribe to Product A in the development environment, while consumer group B subscribes to Product B in the production environment.

    Note

    If multiple consumer groups subscribe to Product B at the same time, each consumer group receives the same message from Device B.

  • Simplifies troubleshooting. You can view the client status, message accumulation, and consumption rate.

  • Provides linear scaling. You can easily scale the push capability if the consumers have sufficient capacity, such as enough client machines.

  • Prioritizes real-time messages. Message accumulation does not affect the service.

    Real-time device messages are pushed directly. If a push is throttled or fails, the message is added to an accumulation queue. Accumulated messages are processed in a degraded mode and do not affect real-time push capabilities.

    If a consumer client goes down or messages accumulate due to insufficient capacity, the consumer can recover. After recovery, new device messages are sent in parallel with accumulated messages. This process prioritizes the resumption of real-time message pushing.

To use an AMQP server-side subscription, first configure the AMQP server-side subscription in the console. For more information, see Configure an AMQP server-side subscription. Then, develop an AMQP client, connect to IoT Platform, and receive messages. For more information, see AMQP client connection guide.

Note

IoT Platform bills you for AMQP server-side subscriptions based on the number of pushed messages. For more information about the billing method, see Message communication billing and Rules engine TPS.

Subscribe to messages using an MNS server-side subscription

IoT Platform pushes subscribed messages to a queue in Simple Message Queue (formerly MNS) (SMQ). Your server's MNS client can then receive device messages by listening to this MNS queue.

The message flow for an MNS server-side subscription is shown in the following figure.

image

For more information about how to configure a subscription to device messages using Message Service, see Use Message Service (MNS) to subscribe to device messages.

Note

Message Service charges fees for the queues that you create and the messages that you receive. For more information about Message Service billing and usage, see Message Service documentation.