All Products
Search
Document Center

ApsaraMQ for Kafka:How do I handle inactive topics?

Last Updated:Jun 27, 2023

Overview

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

Solution

To handle an inactive topic, you must first determine whether the topic is active. If the topic is inactive, you can follow the instructions in the "Delete an inactive topic" section of this topic to delete the inactive topic.

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 time when messages are updated (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:

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

  1. Log on to the ApsaraMQ for Kafka console.

  2. In the top navigation bar, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.

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

  4. In the left-side navigation pane of the Instance Details page, click Topics.

  5. On the Topics page, find the topic whose information you want to view and choose More > Partition Status in the Actions column.

  6. 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 to query the information about all topics

  1. Call the GetTopicList operation to query the 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. Refer to the description in the "Determine whether a topic is active" section of this topic to determine whether each topic is active. 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.

Delete an 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.

  • Do not call API operations to automatically delete topics. Otherwise, irreversible business losses that are caused by program defects occur.

  1. Log on to the ApsaraMQ for Kafka console.

  2. In the top navigation bar, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.

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

  4. In the left-side navigation pane of the Instance Details page, click Topics.

  5. On the Topics page, find the topic that you want to delete and choose image.png > Delete in the Actions column.

  6. In the message that appears, click OK.

    Important

    Before you delete a topic, confirm the information.

References