Reputation: 6905
I can create a KafkaConsumer
via KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)
.
I can also get a List of ConsumerGroups via ListConsumerGroupsResult list = AdminClient.listConsumerGroups()
.
Is there a way to get a KafkaConsumer
from ListConsumerGroupsResult
? From searching via my IDE and online I haven't found such a way but was wondering if anyone in SO community has done this.
Upvotes: 1
Views: 555
Reputation: 5142
If you don't want to query ZooKeeper directly, there is a nice GUI you can use to examin consumers, topics, messages, etc. for a Kafka cluster:
https://github.com/HomeAdvisor/Kafdrop/
It has both a GUI and Restful API.
Upvotes: 1
Reputation: 16834
You can't get a KafkaConsumer
from the consumer groups result. The KafkaConsumer
is what you instantiate to connect to Kafka and to consume data.
I'm assuming you want something like the list of active KafkaConsumer
s at any particular point in time? In this case, you'd have to look at the metadata stored in Zookeeper, using something like zkCli.sh
utility from zookeeper, or a Java Zookeeper client like Curator.
Here's a good reference of the data Kafka stores in Zookeeper, from the official Kafka wiki pages:
https://cwiki.apache.org/confluence/display/KAFKA/Kafka+data+structures+in+Zookeeper
Upvotes: 1