Skip to content
Kafka Is FunProgress

BeginnerOperations

What is enable.auto.commit and why is it dangerous?

Reference answer

enable.auto.commit=true automatically commits offsets at regular intervals (auto.commit.interval.ms=5000). The danger: if the consumer commits offset 100, then crashes before finishing processing message 100, that message is lost (at-most-once risk). Conversely, auto-commit may commit before the application has durably processed the message. Best practice: disable auto-commit and manually call commitSync() or commitAsync() after verifying successful processing.

Expected key concepts: auto.commit, auto.commit.interval.ms, at-most-once, crash, lost, commitSync, commitAsync, manual