CCDAK practice question 8 of 25

How will you set the retention for the topic named “my-topic” to 1 hour?

Full set: 150 questions
Answer options
A: Set the broker config log.retention.ms to 3600000
B: Set the consumer config retention.ms to 3600000
C: Set the topic config retention.ms to 3600000 Correct answer
D: Set the producer config retention.ms to 3600000
Correct Answer:
C. Set the topic config retention.ms to 3600000
Explanation

The retention.ms configuration parameter controls the time-based retention policy for data in a Kafka topic. To configure a specific topic, this parameter must be set at the topic level. This overrides the broker-wide default, which is configured by log.retention.ms. Setting the topic configuration retention.ms to 3600000 directly applies a retention period of 1 hour (60 minutes 60 seconds 1000 ms) specifically to "my-topic". This can be done either when creating the topic or by altering an existing topic's configuration.

Why Incorrect

A. Setting the broker config log.retention.ms applies a default retention policy to all topics on that broker, not specifically to "my-topic".
B. retention.ms is not a valid consumer configuration. Consumers read data but do not manage its retention policy on the broker.
D. retention.ms is not a valid producer configuration. Producers send data but do not control how long it is stored on the broker.

References

1. Confluent Documentation, "Topic-Level Configs": This document lists retention.ms as a per-topic configuration. It states, "This configuration controls the maximum time we retain a log before we discard it to free up space."

Source: Confluent Documentation, Server Configuration Properties, Topic-Level Configs section, retention.ms entry.

2. Apache Kafka Documentation, "Topic-Level Configs": The official Kafka documentation explicitly defines retention.ms as a configuration that can be set for individual topics to control message retention time.

Source: Apache Kafka Documentation, 3.7, Configuration, Topic-Level Configs section.

3. Apache Kafka Documentation, "Broker Configs": This reference distinguishes the broker-level default log.retention.ms from the topic-specific retention.ms. It clarifies that the broker setting is a default, which can be overridden per topic.

Source: Apache Kafka Documentation, 3.7, Configuration, Broker Configs section, log.retention.ms entry.

Scroll to Top