Open metesynnada opened 1 year ago
You need to use another API, as a subscription is only created asynchronously. When you call consumer.subscribe()
it does not block until the subscription is successful. The signal you need to wait for here is the first rebalance call with a Rebalance::Assign(...)
argument in the ConsumerContext
: https://docs.rs/rdkafka/0.29.0/rdkafka/consumer/trait.ConsumerContext.html#method.post_rebalance If you received this, you usually know you are successfully subscribed. AFAIK, there is no other way to find this out. Also AFAIK the consumer.subscription()
will not list all partitions, but only the topics. consumer.assignment()
will only list the partitions assigned to this member in the consumer group, so you need to use the following instead:
You can ask the cluster about your topics via: consumer.client().fetch_metadata(Some("quickstart-events"), None)
even without subscribing to the topic: https://docs.rs/rdkafka/0.29.0/rdkafka/client/struct.Client.html#method.fetch_metadata
I try to discovery the partitions inside the topics I subscribed. Even if it looks simple, I could not manage it with this code
which prints
However,
gives the
I am not sure what I am doing wrong, any guess? I could not find anything on the documentation as well.