Simple Springboot Kafka consumer for test the Kafka Compacted Log feature
[Springboot Producer - Scheduler] -> [Kafka] <- [Springboot Consumer]
Log compaction is a mechanism to give finer-grained per-record retention, rather than the coarser-grained time-based retention. The idea is to selectively remove records where we have a more recent update with the same primary key. This way the log is guaranteed to have at least the last state for each key
- Docker + Docker Compose
- Java 11
- Confluent Kafka
cd confluent-kafka
docker compose up -d
- Open Confluent Control Center http://localhost:9021/
- Create topic account-balance-topic with the custom properties below:
cleanup.policy=compact
min.cleanable.dirty.ratio=0.01
segment.ms=100
delete.retention.ms=100
cd account-balance-producer
mvn spring-boot:run
Leave producing some messages and stop the producer
cd account-balance-consumer
mvn spring-boot:run
The consumer should print a reduced number of messages compared to the producer, because of the log compression configuration.