-
Notifications
You must be signed in to change notification settings - Fork 215
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
Added pause/resume for producers #87
Added pause/resume for producers #87
Conversation
Not sure if it's worth caching the Topic object/partition list inside the producer so it can be reused when resume is called? |
@@ -37,6 +37,7 @@ | |||
#include <set> | |||
#include <librdkafka/rdkafka.h> | |||
#include "macros.h" | |||
#include "metadata.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just use a forward declaration here, this pulls in a bunch of crap that I tried avoided pulling in other headers (e.g. kafka_handle_base.h
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok will do
Woah I didn't know pausing works for producers... Do you have a use case and do you know what happens when you produce into a paused topic/partition? Does it just get buffered for a while? I feel like this should have an overload that takes |
Well apparently the rdkafka documentation for pause/resume does not involve a handle at all and it specifically refers to both production and consumption. For producers you pause when you get throttled. I'm currently implementing some throttling logic on top of cppkafka so i want to be able to pause on both ends. For the producer side, i assume that if you pause, the internal rdkafka queue won't get flushed at all, thus leaving the broker some time to breathe. During this time, all |
I also assume that when pausing the consumer while continuing to poll it, only heartbeats go out and no more batch message requests. |
Actually the pause(topic), resume(topic) should go in the KafkaHandleBase as the implementation is generic to both. I'll push a change asap. |
471be62
to
1e677f5
Compare
1e677f5
to
122b9af
Compare
BTW posted a question for clarification in librdkafka |
Interesting. The author's answer regarding pausing unassigned partitions makes me wonder if this is a valid change. Like he says it may work but they don't guarantee it does. Let's wait for him to answer your last question. |
Tested with the PR pause/resume code as indicated by librdkafka owner and it works fine. Essentially getting the metadata of the partitions makes it known locally and then pausing it works as indicated. I could not use it inside the assignment callback because in cppkafka you call |
Cheers! |
Thanks for this one! |
Added similar helper functions to
consumer::pause
andconsumer::resume
.