Updated on 2024-05-24 GMT+08:00

Changing Kafka Message Retention Period

Aging time is a period that messages in the topic are retained for. Consumers must retrieve messages before this period ends. Otherwise, the messages will be deleted and can no longer be retrieved.

After creating a topic, you can change its aging time based on service requirements. Changing the aging time does not affect services. The default aging time is 72 hours.

You can change the aging time in either of the following ways:

The log.retention.hours parameter takes effect only for topics that have no aging time configured. If there is aging time configured for a topic, it overrides the log.retention.hours parameter. For example, if the aging time of Topic01 is set to 60 hours and log.retention.hours is set to 72 hours, the actual aging time of Topic01 is 60 hours.

Changing Kafka Message Retention Period

  1. Log in to the console.
  2. Click in the upper left corner to select a region.

    Select the region where your Kafka instance is located.

  3. Click and choose Middleware > Distributed Message Service (for Kafka) to open the console of DMS for Kafka.
  4. Click the desired Kafka instance to view the instance details.
  5. In the navigation pane, choose Topics.
  6. Modify the topic aging time using either of the following methods:

    • Select one or more topics and click Edit Topic in the upper left corner.
    • In the row containing the desired topic, click Edit.

  7. In the Edit Topic dialog box, enter the aging time and click OK.