Code Monkey home page Code Monkey logo

Comments (4)

zbweng avatar zbweng commented on September 13, 2024

When "rd_kafka_brokers_add" is called, it will request metadata from Kafka clusters. If the code "sleep(1)" is put after "rd_kafka_brokers_add", the topics information will be ignored when the broker threads receive metadata since "rd_kafka_topic_new" has not been called so far. (Here, the metadata must be received within one second after the request is sent.)

When "rd_kafka_topic_new" is called later, it will not request metadata from Kafka clusters again. Therefore, rdkafka can not send messages because it does not know to which broker the topic corresponds.

I guess you may make a mistake. The upper debug output you pasted above corresponds to the case that you add the code "sleep(1)" while the lower corresponds to the case without the "sleep".

You can see the output "Ignore unknown topic rb_event" in the upper debug infomation since "rd_kafka_topic_new" has not been called at that time. The output "new topic: rb_event" indicates the "rd_kafka_topic_new" is called later.

Solving this issue is easy. Just swap the position of "rd_kafka_topic_new" and "rd_kafka_brokers_add". Call "rd_kafka_topic_new" firstly and then call "rd_kafka_brokers_add". Now the code "sleep(1)" will not affect the result.

from librdkafka.

eugpermar avatar eugpermar commented on September 13, 2024

You are right in both auwzb. I swapped the debug output and I didn't realize I could just set the topic before the brokers. Anyway, I think the correct behavior is you can add a topic anywhere in the code, so I'll let the issue open by the moment.
Thanks a lot for the workaround!

from librdkafka.

zbweng avatar zbweng commented on September 13, 2024

Hi, eugpermar. I am glad that my comment helped.
You suggestion requires that rdkafka must request metadata when a topic is added.

from librdkafka.

edenhill avatar edenhill commented on September 13, 2024

I will push a fix for this soon.

from librdkafka.

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.