Sobes.tech
Junior — Middle

Which Kafka configuration parameters determine the message retention duration in the queue?

sobes.tech AI

Answer from AI

In Apache Kafka, the message retention duration in topics is controlled by the following main configuration parameters:

  • retention.ms — the time in milliseconds for which messages are stored. After this time, messages are deleted from the topic.
  • retention.bytes — the maximum size of data that can be stored in a partition. If this size is exceeded, old messages are deleted.

These parameters can be set at the topic level or globally for the broker. For example, to store messages for 7 days, you can set retention.ms=604800000.

Example of setting retention for a topic using the kafka-topics command:

kafka-topics.sh --alter --topic my_topic --config retention.ms=604800000

Thus, the message retention duration is regulated by time and/or storage size.

Which Kafka configuration parameters determine the… - sobes.tech