本文介绍了kafka-console-consumer 使用什么消费群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我像这样运行 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 with console-consumer-.

这篇关于kafka-console-consumer 使用什么消费群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 02:56