All Products
Search
Document Center

ApsaraMQ for Kafka:How do I handle inactive topics?

Last Updated:Dec 02, 2024

This topic describes how to handle historical or inactive topics to reduce the amount of occupied resources.

Process

1. Determine whether a topic is active

The following table describes the key metrics that are used to determine whether a topic is active.

Total number of messages on the broker (TotalCount)

Most recent update time of messages (LastTimeStamp)

In most cases, if the value of the TotalCount parameter is 0, the topic is inactive.

In most cases, if the value of the LastTimeStamp parameter specifies a time long ago, the topic is inactive.

Note

If the value of the LastTimeStamp parameter is 0 or a negative value, the system does not obtain the timestamp. In this case, do not mark the topic as inactive.

You can use one of the following methods to obtain the values of the preceding key metrics:

Use the console

View the topic information of the instance in the ApsaraMQ for Kafka console.

  1. Log on to the ApsaraMQ for Kafka console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides. On the Instances page, click the name of the instance that you want to manage.

  3. In the left-side navigation pane, click Topics. On the page that appears, click the name of the topic that you want to manage.

  4. On the Topic Details page, click the Partition Status tab.

  5. Determine whether the topic is active. If the topic is inactive, record the topic name. Then, follow the instructions in the "Delete an inactive topic" section of this topic to delete the inactive topic.

Call API operations

Call API operations to query information about all topics.

  1. Call the GetTopicList operation to query information about all topics. For information about how to call this operation, see GetTopicList.

  2. Call the GetTopicStatus operation to query the messaging status of each topic. For information about how to call this operation, see GetTopicStatus.

  3. Record the values of the LastTimeStamp and TotalCount parameters of each topic in the response.

  4. To determine whether each topic is active, refer to the description in the "Determine whether a topic is active" section of this topic. If inactive topics exist, record the topic names. Then, follow the instructions in the "Delete an inactive topic" section of this topic to delete the inactive topics.

2. Delete the inactive topic

You can perform the following steps to delete an inactive topic to reduce the amount of occupied resources:

Warning
  • You must determine whether an inactive topic is to be deleted.

  • We recommend that you do not call API operations to automatically delete topics. Otherwise, program errors may occur and cause irreversible business losses.

  1. Log on to the ApsaraMQ for Kafka console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where the instance that you want to manage resides. On the Instances page, click the name of the instance that you want to manage.

  3. In the left-side navigation pane, click Topics. On the page that appears, click the name of the topic that you want to manage.

  4. In the upper-right corner of the Topic Details page, click Delete.

  5. In the message that appears, click OK.

    Important

    Confirm the information before you delete a topic.