Extra Credit
- Create a topic called
"compacted-expiring-topic"
using thekafka-topics
command - Make sure the topic has a combined cleanup policy and the proper retention and segment timings
- Essentially combine the configurations used in the previous two exercises
- Repeat the exercise steps from either 1.a.1 or 1.b.1, but make sure you set the
"generate-test-data.ps1"
mode to"retention-policy-delete-publisher"
.
- What configurations do you think you need to set for the kafka topic?
- What happens if you miss one of these configurations?
- Observe Kafka's and the client's behavior in this case. What do you expect the end result would be?
Click to view the correct command...
The command you should use to create the topic is the following:
./kafka-exec.ps1 "kafka-topics --bootstrap-server=localhost:9092 --create --partitions=1 --replication-factor=3 --topic=compacted-expiring-topic --config cleanup.policy="compact,delete" --config retention.ms=60000 --config segment.ms=30000 --config min.cleanable.dirty.ratio=0.01"
You will see both types of logs - the ones present in the expiration and compaction exercise at the same time. The data in the topic will be compacted at some point and at a later stage, given that no messages are produced, all previously produced messages will expire and the topic will be left empty.