gpt4 book ai didi

apache-kafka - 如何在Kafka的命令行中获取主题的group.id?

转载 作者:行者123 更新时间:2023-12-04 04:09:42 25 4
gpt4 key购买 nike

我在服务器上安装了kafka,并想学习如何使用它,
我找到了由scala编写的示例代码,下面是其中的一部分,

def createConsumerConfig(zookeeper: String, groupId: String): ConsumerConfig = {
val props = new Properties()
props.put("zookeeper.connect", zookeeper)
props.put("group.id", groupId)
props.put("auto.offset.reset", "largest")
props.put("zookeeper.session.timeout.ms", "400")
props.put("zookeeper.sync.time.ms", "200")
props.put("auto.commit.interval.ms", "1000")
val config = new ConsumerConfig(props)
config
}

但我不知道如何在服务器上找到组ID。

最佳答案

group id是您通过为消费者提供自己的字符串ID来定义自己的东西。以相同ID开头的所有使用者将以协作的方式“协作”并阅读主题,其中每个使用者实例将处理主题中消息的子集。提供不存在的组ID将被视为新使用者,并在Zookeeper中创建一个新条目,其中将存储已提交的偏移量。

关于apache-kafka - 如何在Kafka的命令行中获取主题的group.id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34492958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com