首页 > 解决方案 > 尝试删除 Kafka 中的消费者组时出现 GroupNotEmptyException

问题描述

我执行了

"kafka-consumer-groups --bootstrap-server localhost:9092 --list" 

这会导致显示一组:console-consumer-961

然后我试图删除这个组:

kafka-consumer-groups --bootstrap-server localhost:9092 --delete --group console-consumer-961

但这会导致异常:

Error: Deletion of some consumer groups failed:
* Group 'console-consumer-961' could not be deleted due to: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.GroupNotEmptyException: The group is not empty.

我猜这个组是在我运行 kafka- 时创建的console-consumer.bat,但现在这个消费者没有运行。如何删除此消费者组?

标签: apache-kafkakafka-consumer-api

解决方案


kafka-consumer-groups您可以使用命令行工具来验证消费者组的状态。

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group console-consumer-961 --state

This will show you the state of the consumer. If it is not empty, Kafka will not allow to delete that group. If it still shows that your console consumer is running you need to make sure to properly shut it down (usually by CTRL+C)


推荐阅读