Skip to content

How EventListener#onEvent is executed? #32

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

Closed
ngocdaothanh opened this issue Mar 19, 2015 · 3 comments
Closed

How EventListener#onEvent is executed? #32

ngocdaothanh opened this issue Mar 19, 2015 · 3 comments
Labels

Comments

@ngocdaothanh
Copy link

This may be related to #15.

I think readme.md should mention how EventListener#onEvent is executed.

Is it executed by the network IO thread of mysql-binlog-connector-java? If I have a blocking logic inside onEvent, will it cause mysql-binlog-connector-java to stop reading new binlog events? Should I run my logic in separate thread that I manage on my own?

I want to write a high performance data replicator, so I don't want to block mysql-binlog-connector-java from reading new binlog events while my replicator logic runs.

@shyiko
Copy link
Owner

shyiko commented Mar 20, 2015

Hi.

This may be related to #15.

That ticket is more about refactoring than anything else.

Is it executed by the network IO thread of mysql-binlog-connector-java?

Information on whether separate thread is started is in javadocs (connect and connect(timeout)). onEvent is always invoked within the same (original or spawned (depending on which connect is being used)) thread.

If I have a blocking logic inside onEvent, will it cause mysql-binlog-connector-java to stop reading new binlog events?

Yes. mysql-binlog-connector-java makes no assumption about how it's going to be used. It's up to the user to implement some kind of queue (hopefully with back pressure mechanism in place) if he deems necessary.

Should I run my logic in separate thread that I manage on my own?

If you want to squeeze every bit of performance (like in your case) then yes. It sure seems like it.

@ngocdaothanh
Copy link
Author

Thanks for the great info 👍
I'll improve my program based on your advice.

May be you should add it to readme.md because it's important and people rarely read everything in the Javadoc.

Also, it's more convenient if you publish the Javadoc online, for example, using the Github Pages feature.

@shyiko
Copy link
Owner

shyiko commented Mar 20, 2015

Good point. Reopening issue as a reminder. Thank you.

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

No branches or pull requests

2 participants