A server can subscribe to various types of product messages. These messages include device upstream messages, device status changes, gateway and sub-device connections, device lifecycle changes, and device topology changes. After you configure server-side subscription, IoT Platform forwards the subscribed messages from all devices of the product to your server.

Scenarios

Server-side subscription can be applied to the following scenarios:

  • Your server receives upstream messages from a large number of devices at the same time.
  • Your server receives subscribed messages from all devices of a product.
Note 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 the difference between server-side subscription and data forwarding, see Compare data forwarding solutions.

Use an AMQP server to subscribe to device messages

AMQP refers to Advanced Message Queuing Protocol. After you configure AMQP server-side subscription, IoT Platform forwards all subscribed device messages of a product to your server over AMQP.

The following figure shows how messages are forwarded in AMQP server-side subscription.

AMQP

Benefits of AMQP server-side subscription:

  • Supports multiple consumer groups. You can create multiple consumer groups for different environments. For example, you can create two consumer groups: Group A and Group B. Group A subscribes to the messages of Product A in the development environment and Group B subscribes to the messages of Product B in the production environment.
    Note If multiple consumer groups subscribe to the messages of Product B, the consumer groups can receive the same messages from Product B at the same time.
  • Facilitates troubleshooting. Server-side subscription allows you to view the client status, accumulated messages, and message consumption rate.
  • Supports linear scalability. You can significantly improve the message forwarding capability by adding consumer clients.
  • Pushes real-time messages first. Message accumulation does not affect the service.

    Real-time messages take precedence over accumulated messages if the push rate limit is reached or failures occur.

    Even if messages are accumulated due to client failures or low consumption rates, real-time messages are sent with accumulated messages after clients recover. Then, devices can push messages in real time again.

Before you use AMQP server-side subscription, you must configure it in the console. For more information, see Configure an AMQP server-side subscription. You must develop an AMQP client and connect it to IoT Platform. Then, you can use the client to receive messages. For more information, see Connect an AMQP client to IoT Platform.

Note After you enable AMQP server-side subscription in the IoT Platform, you are billed based on the number of forwarded messages. For information about the billing methods, see Messaging fees.

Use the MNS server to subscribe to device messages

After you configure MNS server-side subscription, IoT Platform forwards subscribed messages to Message Service (MNS) queues. The MNS client in your server receives device messages by listening to the MNS queues.

The following figure shows how messages are forwarded in MNS server-side subscription.

MNS

For information about how to configure MNS server-side subscription, see Use Message Service (MNS) to subscribe to device messages.

Note You are billed based on the queues that you create and the messages that you receive. For more information about the billing methods, see Message Service documentation.