Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set Kafka Stream consumer group.id?

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");

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

Can I set kafka stream consumer group.id??

like image 275
Jeahyun Kim Avatar asked Mar 19 '19 08:03

Jeahyun Kim


People also ask

Is group.id mandatory for Kafka consumer?

The consumer group-id is mandatory, it plays a major role when it comes to scalable message consumption. To start a consumer group-id is mandatory.

What is group.id config in Kafka?

group.id specifies the name of the consumer group a Kafka consumer belongs to. When the Kafka consumer is constructed and group.id does not exist yet (i.e. there are no existing consumers that are part of the group), the consumer group will be created automatically.

What is default group.id in Kafka?

Public Interfaces. The default group id will change from "" to null so that consumers that want to use an empty ( "" ) group id would have to explicitly specify it. The use of empty group id will be deprecated on the client, and consumers using this group id will receive a warning about this deprecation.


1 Answers

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

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

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

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
like image 188
mukesh210 Avatar answered Sep 18 '22 08:09

mukesh210