All Products
Search
Document Center

ApsaraMQ for MQTT:Clear subscriptions for a topic

更新時間:Sep 25, 2023

This topic describes how to configure the subscription cleanup feature for a specified topic in the ApsaraMQ for MQTT console.

Background information

The following items provide the background and billing information about the subscription cleanup feature:

  • After the subscription cleanup feature is configured for a topic, ApsaraMQ for MQTT deletes the subscription between the subscriber and the topic if the subscriber client keeps offline for a period of time that exceeds the specified limit. If the subscription is not cleared, the subscription remains valid when the subscriber client is offline. When the client goes online again, ApsaraMQ for MQTT automatically loads offline messages and sends them to the client.

  • Assume that you have a freshness requirement for offline messages or you determine that a subscriber is invalid and is no longer needed for specific business. In this case, you can enable this feature to clear the subscriptions between the subscriber and the topics to which it subscribed.

  • ApsaraMQ for MQTT determines whether to automatically load offline messages and send them to the client based on the values of the QoS and cleanSession parameters. For more information, see Terms.

  • Subscription changes affect the billing of the related instance. For more information, see Billing overview.

Procedure

Warning

If you enable the subscription cleanup feature, the client cannot receive offline messages. Proceed with caution.

  1. Log on to the ApsaraMQ for MQTT console and click Instances in the left-side navigation pane.
  2. In the top navigation bar, select a region. On the Instances page, click the ID of the instance that you want to manage. The Instance Details page appears.
  3. On the left-side navigation pane, click Topics, find the topic for which you want to configure the subscription cleanup feature, and then choose More > Subscription Cleanup in the Actions column.

  4. In the Configure Automatic Cleanup Cycle panel, set Enable Automatic Subscription Cleanup and Cleanup Cycle, and click OK.

    • If you set Enable Automatic Subscription Cleanup to Yes, the system clears the subscription between the subscriber and the topic if the value obtained by subtracting the last heartbeat time of the client from the current system time is no less than the value of Cleanup Cycle. After the subscription is cleared, the client can no longer receive offline messages generated by the topic.

      Important

      When the client goes online again, it can still receive offline messages that are generated before the subscription is cleared and are within the validity period.

    • If you set Enable Automatic Subscription Cleanup to No, the system does not clear the subscription between the subscriber and the topic when the subscriber client is offline. The subscription remains valid.

    After the configuration is complete, you can view the subscription cleanup cycle in the Subscription Cleanup Cycle column of the topic.