I changed the consumer-group-id of my web service listening to a Kafka topic. Now, the old group id is still registered to the topic, but there is no consumer with that group id. Therefore, it is lagging. How can I remove a specific consumer group from a specific topic?
I tried this:
kafka-consumer-groups --bootstrap-server kafka01.myserver.com:9092 --topic notification-topic --delete --group old-consumer-group --execute
But it returns: "The consumer does not support topic-specific offset deletion from a consumer group."
Should I remove the consumer group totally? I use the same group id listening to other topics, are they going to be affected?
You can delete consumer groups from Kafka instances by using the Kafka command line tool of your Kafka client. NOTE: Ensure that the client uses the same version as the Kafka instance. [root@zk-server-1 bin]# ./kafka-consumer-groups.sh --bootstrap-server 172.31.
Kafka Consumer Groups A consumer group has a unique id. Each consumer group is a subscriber to one or more Kafka topics. Each consumer group maintains its offset per topic partition. If you need multiple subscribers, then you have multiple consumer groups.
Delete a consumer-group: deletion is only available when the group metadata is stored in zookeeper (old consumer api). With the new consumer API, the broker handles everything including metadata deletion: the group is deleted automatically when the last committed offset for the group expires.
This can be done using the kafka-delete-records.sh tool to read a configuration file (JSON format) that describes the records we want to be deleted. The example in the listing below can be used to remove all messages from the test-topic created earlier. The contents of the file should be saved as delete-test.
Starting with Kafka 2.4.0 it is possible to delete individual consumer group id offsets from a topic.
The call is very close to what you have already tried, but requires --delete-offsets
instead of --delete
:
./kafka-consumer-groups.sh \
--bootstrap-server <bootstrap-server-url> \
--delete-offsets \
--group <my-group> \
--topic <topic-name>
To date this is not reflected in the official documentation (Kafka 2.7.0 and below). However, it is described in a confluence document of improvement proposal KIP-496 that has been implemented and released.
You cannot remove a specific group on its own, nor a topic from a group.
Consumer groups remain available based on the retention you've defined for the offsets topic on the broker. There is no performance impact by having lagging groups that are not being consumed.
Note: Every time you use kafka-console-consumer
, a brand new group is created.
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