我可以设置Kafka Stream消费者group.id吗? [英] Can I set Kafka Stream consumer group.id?

查看:23
本文介绍了我可以设置Kafka Stream消费者group.id吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Kafka Stream 库用于流式应用程序.我想设置 kafka 消费者组 ID.然后,我把 Kafka 流配置如下.

I'm using Kafka Stream library for streaming application. I wanted to set kafka consumer group id. Then, I put Kafka stream configuration like below.



    streamsCopnfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "JoinTestApp");
    streamsCopnfiguration.put(StreamsConfig.CLIENT_ID_CONFIG, "JonTestClientId1");
    streamsCopnfiguration.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 10 * 1000);
    streamsCopnfiguration.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, bootstreapServer);
    streamsCopnfiguration.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
    streamsCopnfiguration.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.Bytes().getClass().getName());
    streamsCopnfiguration.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    streamsCopnfiguration.put(StreamsConfig.consumerPrefix("group.id"), "groupId1");
//    streamsCopnfiguration.put(ConsumerConfig.GROUP_ID_CONFIG, "groupId1");

但是,我的控制台日志 kafka 消费者配置没有设置 group.id.只需流式传输应用程序 ID..

But, my console log kafka consumer configuration not seted group.id. Just stream application id..

2019-03-19 17:17:03,206 [main] INFO  org.apache.kafka.clients.consumer.ConsumerConfig - ConsumerConfig values: 
auto.commit.interval.ms = 5000
auto.offset.reset = earliest
bootstrap.servers = [....]
check.crcs = true
client.dns.lookup = default
client.id = JonTestClientId111-StreamThread-1-consumer
connections.max.idle.ms = 540000
default.api.timeout.ms = 60000
enable.auto.commit = false
exclude.internal.topics = true
fetch.max.bytes = 52428800
fetch.max.wait.ms = 500
fetch.min.bytes = 1
group.id = JoinTestApp
heartbeat.interval.ms = 3000
interceptor.classes = []
internal.leave.group.on.close = false

我可以设置 kafka 流消费者 group.id 吗??

Can I set kafka stream consumer group.id??

推荐答案

不,你不能. 为此,你需要在 Kafka Streams 中使用 application.id.

No, you can't. For this purpose in Kafka Streams you need to use application.id.

Kafka Streams application.id 用于在不同的地方将应用程序使用的资源与其他资源隔离开来.

Kafka Streams application.id is used at various places to isolate resources used by application from others.

application.id 用作 Kafka 消费者 group.id 进行协调.这就是为什么您不能显式设置 group.id 的原因.

application.id is used as Kafka consumer group.id for coordination. That's why you can not set group.id explicitly.

来自 Kafka Streams 官方文档application.id 也用在以下地方:

From Kafka Streams Official documentation, application.id is also used at following places:

 - As the default Kafka consumer and producer client.id prefix
 - As the name of the subdirectory in the state directory (cf. state.dir)
 - As the prefix of internal Kafka topic names

这篇关于我可以设置Kafka Stream消费者group.id吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆