I'm using kafka-python and I'm wondering if there is a way for showing all the topics.
Something like this:
./bin/kafka-topics.sh --list --zookeeper localhost:2181
I'm using kafka-python and I'm wondering if there is a way for showing all the topics.
Something like this:
./bin/kafka-topics.sh --list --zookeeper localhost:2181
import kafka
consumer = kafka.KafkaConsumer(group_id='test', bootstrap_servers=['server'])
consumer.topics()
You need to use the KafkaAdminClient
, not KafkaConsumer
:
import kafka
admin_client = kafka.KafkaAdminClient(bootstrap_servers=['server'])
admin_client.list_topics()
Try with the method KafkaConsumer.topics().
© 2022 - 2024 — McMap. All rights reserved.