Offset Commit Configuration
This lesson explains the various configurations that can affect how offsets are committed.
Automatic Commit
Offsets can be automatically committed by the consumer using the configuration enable.auto.commit=true
. You can use the configuration auto.commit.interval.ms
to control how frequently the commits happen. By default, the frequency is set to 5 seconds. Automatic commits happen when the method poll()
is invoked. The method checks if auto.commit.interval.ms
seconds have elapsed since the last commit. If so, it commits the offset from the last poll()
invocation (not the current one). Below is a pictorial representation of how the automatic commit works. We assume that each poll()
returns four records and the auto commit interval defaults to 5 seconds.
Get hands-on with 1400+ tech skills courses.