Offsets, Seeking and Replay
Control where a consumer starts, and rewind a group on purpose without guessing.
Open this lesson in the learning hubKey points
auto.offset.resetapplies only when a group has no committed offset for a partition: earliest, latest or none.- It is not a replay switch. An existing group already has offsets, so changing the setting and restarting does exactly nothing.
- To replay: stop every member, then
--reset-offsetswith--to-earliest,--to-datetimeor a shift. - Run it with
--dry-runfirst. It prints the offsets it would write;--executeis what actually commits them. - In code,
seek()after the firstpoll(), or from aConsumerRebalanceListener. - A replay re-runs every side effect. Only ever replay into handlers you know are idempotent.
Example
# Where is the group now? Stop all members first -- a live group refuses a reset.
kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
--describe --group billing-service
# Dry run: prints target offsets, writes nothing
kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
--group billing-service --topic orders \
--reset-offsets --to-earliest --dry-run
# Replay everything since a point in time
kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
--group billing-service --topic orders \
--reset-offsets --to-datetime 2026-07-01T00:00:00.000 --execute
# Nudge one partition back 500 records:
# --topic orders:3 --reset-offsets --shift-by -500 --execute
auto.offset.reset is for new groups only. Replay is a deliberate, dry-run-first offset reset.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kafka course, and every lesson in it is listed on the Kafka contents page.