-
Notifications
You must be signed in to change notification settings - Fork 820
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
How is keepalive supposed to work? #118
Comments
Hi @snaury. You're right. MySQL never actually reacts to A correct way (at least the way I see it) is to use Regarding A few notes that might or might not be useful:
you can register LifecycleListener to get some visibility into what is going on at any point of time
This is what Let me know if something doesn't make sense or you have some other ideas. Thank you! |
Yes, I figured that and would probably do that. However due to event listener the logic becomes somewhat inverted. Consider the following example code, how I see it: Event event;
boolean haveBufferSpace = true;
while (haveBufferSpace && (event = client.readEvent()) != null) {
// complex event handling logic, batching, etc.
// there may be some fatal exceptions due to which the program must audibly fail
} With the current API I have to put the body of the while loop into the event listener, have complex buffer flushing logic in there as well, I have to effectively |
Like I said, the API is going to simplified in 1.0.0. Meanwhile, maybe you could (just an example) use a blocking queue to which EventListener would enqueue the events? In that case consumer (your while loop & all the logic) would be decoupled from the source (BinaryLogClient) + it wouldn't matter whether BinaryLogClient is running on separate thread or not. An actual code could look very much alike to what you specified above. |
Hey @snaury. I've just uploaded 0.10.0 to Maven Central. It contains proper keepAlive mechanism (using HEARTBEAT event described above). Anyway, I understand that you guys don't use built-in keepAlive but you still might find BinaryLogClient::heartbeatInterval useful. Take a look. |
Thank you! That's useful even when not using a keepalive thread, but you should be careful, because documentation states:
So you should update |
I'm wondering how keepalive is supposed to work, because it seems it doesn't:
COM_BINLOG_DUMP/_GTID
packet, untilmysql_binlog_send
returnsWould it be possible to change the API to a more user-friendly workflow? Something like this:
connect
would connect, authenticate and start binlog dumping, but return immediately otherwisereadEvent
would (synchronously) read the next event, instead of a separate thread making callbacks, this way it would be easily to control and exceptions would naturally bubble-up to the application loop (this would also make it similar toBinaryLogFileReader
)readEvent
, again making it easier for exceptions to bubble-upThe text was updated successfully, but these errors were encountered: