The question/answer you are referring to is based on an older Kafka version. Since Kafka 0.9, offsets are not committed to ZooKeeper but store in a special Kafka topic called the offset topic (topic name is __consumer_offsets
).
Since Kafka 1.0, the command line tool bin/kafka-consumer-groups.sh
has a new feature that allow to set offsets. Check out the original KIP: https://cwiki.apache.org/confluence/display/KAFKA/KIP-122%3A+Add+Reset+Consumer+Group+Offsets+tooling
The tool also works for Kafka 0.11 (and maybe even older Kafka versions).
An alternative is to write your own tool, that uses an single KafkaConsumer
with the corresponding group.id
, subscribe to the topic(s) you want to modify offsets for, seek()
and commit()
offsets. (Note, you should disable auto commit for this consumer.)
/home/centos/kafka_2.12-0.10.2.0/bin/kafka-consumer-groups.sh --bootstrap-server 1.1.1.1:9092,1.1.1.2:9092 --reset-offsets --group sample-app-0.0.1 --topic abc --to-offset 76756952
Exception:Exception in thread "main" joptsimple.UnrecognizedOptionException: reset-offsets is not a recognized option
. Is this option not available in 0.10.2.0. – Cabinda