Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way for a publisher in the delivery callback to know which partition it was sent to? #38

Closed
winbatch opened this issue Dec 27, 2013 · 3 comments

Comments

@winbatch
Copy link

If I am letting the broker determine the partition based on key, is there a way the publisher can tell which partition was chosen? I'd like to log it.

@winbatch
Copy link
Author

Is that what the topic_set_partitioner_cb() is for? unclear to me.

@edenhill
Copy link
Contributor

The broker does not decide on the partition, that is up to the producer.

If you produce a message through librdkafka with the partition set to -1 (or RD_KAFKA_PARTITION_UA (unavailable)) then the configured partitioner will be called for the message.
If there is no configured partitioner the default partitioner is used which is a random partitioner.

There is unfortunately no support in the delivery report callback (dr_cb) for seeing which partition was used.
But you can configure your own partitioner function to decide which partition to send a message to. It will be called once for each message you produce and it allows you to check if a certain partition is available.
See https://github.com/edenhill/librdkafka/blob/master/rdkafka.h#L287

@edenhill
Copy link
Contributor

edenhill commented Jan 4, 2014

Please reopen this issue if anything is unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants