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

Do you have to specify a callback function for the rd_kafka_poll() to work? #37

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

Comments

@winbatch
Copy link

I indicated request.required.acks=1 and am polling in a loop until I get a return value of 1. I have not specified a callback function (I may do this later), but I find that it doesn't ever seem to return 1? Is a callback function required?

In a different program I do have a callback function and it seems to work as expected.

@edenhill
Copy link
Contributor

You will need to set a dr_cb (delivery report callback) and then call rd_kafka_poll() to get indication if a message was delivered or not.

Use rd_kafka_conf_set_dr_cb(), you can look at examples/rdkafka_performance.c for an example.

Even if you dont set a dr_cb, librdkafka will respect your request.required.acks setting and make sure the message does indeed receive the requested number of acks, or else it will retry the transmission.

@winbatch
Copy link
Author

I'm pretty sure poll never returns 1 though if no callback is specified
which surprised me

On Friday, December 27, 2013, Magnus Edenhill wrote:

You will need to set a dr_cb (delivery report callback) and then call
rd_kafka_poll() to get indication if a message was delivered or not.

Use rd_kafka_conf_set_dr_cb(), you can look at
examples/rdkafka_performance.c for an example.

Even if you dont set a dr_cb, librdkafka will respect your
request.required.acks setting and make sure the message does indeed receive
the requested number of acks, or else it will retry the transmission.


Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-31282919
.

@edenhill
Copy link
Contributor

rd_kafka_poll() simply returns the number of internal events served, and not all of them depend on the application having configured a callback.
For instance if no error callback is configured the errors are converted into log messages instead.
So you shouldn't use the return value of rd_kafka_poll() to indicate any sort of produce message success, you need the delivery report callback (dr_cb) for that.

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