Skip to content

Instantly share code, notes, and snippets.

@dmusicant-dk
Created June 13, 2023 21:48
Show Gist options
  • Save dmusicant-dk/62412856c7279051cdfa5f350761971f to your computer and use it in GitHub Desktop.
Save dmusicant-dk/62412856c7279051cdfa5f350761971f to your computer and use it in GitHub Desktop.

Extra Credit

Instructions

  1. Create a topic called "compacted-expiring-topic" using the kafka-topics command
  2. Make sure the topic has a combined cleanup policy and the proper retention and segment timings
    1. Essentially combine the configurations used in the previous two exercises
  3. 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".

Questions To Consider

  1. What configurations do you think you need to set for the kafka topic?
    1. What happens if you miss one of these configurations?
  2. Observe Kafka's and the client's behavior in this case. What do you expect the end result would be?

Answer

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment