feat: retention example

This commit is contained in:
2026-01-25 03:03:25 +00:00
parent 7c59136cc1
commit 15c93c71fb
4 changed files with 105 additions and 0 deletions
+14
View File
@@ -71,3 +71,17 @@ DELETE topic:
```
docker exec -it kafka-keys /opt/kafka/bin/kafka-topics.sh --delete --topic keys-topic --bootstrap-server localhost:9092
```
# 05-retention
5000 ms = 5 seconds of retention
```
sudo chown -R 1000:1000 kafka-data
sudo docker exec kafka-ret /opt/kafka/bin/kafka-topics.sh --create --topic ret-topic --partitions 1 --bootstrap-server localhost:9092 --config retention.ms=5000 --config segment.ms=2000
```
Kafka moves on from one log file to another based on size or time. These are called "segments". Each segment is a file on disk. Nothing is EVER deleted from the active segment. Only when a segment is "closed" ( rolled over to a new segment ) can it be deleted based on retention policy.
Just retention above won't work, I need to roll it over too.