Giter VIP home page Giter VIP logo

Comments (3)

mrtheb avatar mrtheb commented on May 8, 2024

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.

mrtheb avatar mrtheb commented on May 8, 2024

@roycamp, did you have a chance to try my suggestions, do you have any feedback on that?

from kafka-python.

dpkp avatar dpkp commented on May 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.