问题描述
当我像这样运行kafka-console-consumer时
When i run kafka-console-consumer like so
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
它默认为哪个消费群体?如果我没有在命令行中指定使用者组或链接到使用者属性,它最终会使用随机使用者组吗?如何检查使用了哪个消费群体?
What consumer group does it default to? Does it end up using a random consumer group if I don't specify consumer group or link to consumer properties in the command line? How can I check what consumer group was used?
谢谢!
推荐答案
如果未指定组,则kafka-console-consumer.sh
会生成具有以下格式的随机使用者组:
If a group is not specified, the kafka-console-consumer.sh
generates a random consumer group with this format:
console-consumer-${new Random().nextInt(100000)}
请参阅ConsoleConsumer scala类: https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/tools/ConsoleConsumer.scala#L370
See the ConsoleConsumer scala class: https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/tools/ConsoleConsumer.scala#L370
不幸的是,要找到生成的组ID,您必须:
Unfortunately to find the generated group id, you have to:
- 查看控制台使用者日志
- 列出所有组(例如,使用
kafka-consumer-groups
工具并过滤以console-consumer-
开头的组.
- look at the console consumer logs
- list all groups (for example using the
kafka-consumer-groups
tool and filter for group starting withconsole-consumer-
.
这篇关于kafka-console-consumer消费者使用什么消费群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!