Kellyz Introduces Zero-Downtime Offset Shifting Using Spring Kafka's ConsumerSeekAware
Key point
Kellyz's Order Platform Development team combined Spring Kafka's ConsumerSeekAware with Redis Pub/Sub to shift offsets without stopping the consumer group.
Details
Kellyz's Order Platform Development team introduced a method to shift offsets and reprocess messages without stopping the consumer group in a distributed system environment using Spring Kafka. Previously, the team used the Kafka CLI or the alterConsumerGroupOffsets API, but these methods only worked when the consumer group was inactive, causing application downtime. This was a major cause of reduced availability for the 'Kelly Now' service, which guarantees real-time delivery.
The new approach utilizes ConsumerSeekCallback and AbstractConsumerSeekAware. Spring Kafka internally supports the Consumer#seek API, which allows dynamically changing the offset of a specific partition. The application receives offset-shift requests via Redis Pub/Sub, and each consumer instance calls the seekToBeginning or seek method for its assigned partitions to adjust the processing position. This process is performed without rebalancing the consumer group or restarting the application.
For implementation, Spring Kafka 3.3.0 and later versions use the getTopicsAndCallbacks() method to safely manage callbacks. This resolves the callback omission issue that occurred in earlier versions and prevents conflicts when multiple consumer groups subscribe to the same topic. This structure allows developers to independently control offsets without needing permissions, minimizing message Lag processing delays and securing the stability of real-time data processing.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.