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

查看:204
本文介绍了我可以设置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天全站免登陆