Comments (3)
By continuous discovery, do you imply being notified (asynchronously) whenever the list of brokers of topic metadata gets updated? Did you ask your question on the kafka user mailing list?
Otherwise, the library has the topic information but it is somewhat hidden in the KafkaClient
. The list of brokers and topic metadata (topic_partitions) is loaded by the client as construction (see load_metadata_for_topics). You can access them using the client instance.
IMO, the best option at the moment if you want to be notified on the spot upon brokers and topic metadata changes is still to use a connection to zookeeper with watches (see kazoo).
from kafka-python.
@roycamp, did you have a chance to try my suggestions, do you have any feedback on that?
from kafka-python.
To get all the topics in a cluster, you should send a metadata request to one of the brokers and have your application logic manage finding "new" topics:
from kafka.conn import KafkaConnection
from kafka.protocol import KafkaProtocol
# some config settings
host = 'srv-130-12'
port = 9092
client_id = "topic_checker" # any str will do here
request_id = 0 # any int will do here
correlation_id = 0 # any int will do here
conn = KafkaConnection(host, port)
request = KafkaProtocol.encode_metadata_request(client_id, correlation_id)
conn.send(request_id, request)
response = conn.recv(request_id)
(brokers, topics) = KafkaProtocol.decode_metadata_response(response)
print topics.keys()
from kafka-python.
Related Issues (20)
- CPU spikes upon broker replacement HOT 1
- [Python 3.12.0] ModuleNotFoundError: No module named 'kafka.vendor.six.moves' HOT 4
- kafka.errors.NodeNotReadyError: NodeNotReadyError HOT 1
- Drop support for EOLed Python versions HOT 7
- Question about group.instance.id
- Support for Python versions >=3.9 HOT 27
- An exception occurs when the ConsumerCoordinator object is being deleted HOT 1
- When will be release on PyPi? Waiting for 3.12 support. HOT 1
- Add list of topics/consumers method to get consumers with the specific topic
- "import kafka" fails with "ModuleNotFoundError: No module named 'kafka.vendor.six.moves'" under Python 3.12 HOT 10
- Manual Offset Commit/Heartbeat Deadlock HOT 1
- Misdetection of xerial snappy on RedPanda
- One of the `_retrieve_offsets` calls is missing the `timeout_ms` variable - this leads to an infinite while loop
- Long running processes causing Heartbeat session expirations HOT 2
- Advice needed. How to connect to Kafka with Private Key Certificate
- Can the Private Key and Password be stored in memory instead of a file?
- Trying to Reuse Kafka Instance Fails
- Messages exceeding the size are silently dropped HOT 1
- invalid literal for int() with base 10: 'A.B.C.D' HOT 1
- MAINTAINER NOTICE: RELEASES ARE CURRENTLY PAUSED HERE, VISIT THE FORK HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kafka-python.