I try to shift back the offset of topic within consumer group using following command:
bin/kafka-consumer-groups.sh --bootstrap-server loclahost:9092 --group xxx-0 --topic schedule-changed --reset-offsets --shift-by -2 --execute
(Yes, I'm using kafka version > 1.x) As a result I got a message:
Error: Assignments can only be reset if the group 'xxx-0' is inactive, but the current state is Stable.
How can I change the state of group from 'stable' to 'inactive'?
How to change consumer offset? Use the kafka-consumer-groups.sh to change or reset the offset. You would have to specify the topic, consumer group and use the –reset-offsets flag to change the offset.
Second, use auto. offset. reset to define the behavior of the consumer when there is no committed position (which would be the case when the group is first initialized) or when an offset is out of range. You can choose either to reset the position to the “earliest” offset or the “latest” offset (the default).
The reset-offsets
option for kafka-consumer-groups.sh first checks to see if a consumer is active in that group before attempting to shift back your offsets. 'Stable' means you have an active consumer running.
Use the describe-groups
option to check on your consumer groups:
bin/kafka-consumer-groups.sh --bootstrap-server $SERVERS --group $GROUP --describe
If you see an entry under 'CONSUMER-ID/HOST/CLIENT-ID' for your topic, that means you still have a consumer running. Once you shut down the app that's keeping the consumer alive your consumer group will be inactive and you'll be able to shift your offsets at will.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With