Skip to content

How to listen to multiple databases at the same time? #166

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

Open
slowside45 opened this issue Apr 11, 2025 · 3 comments
Open

How to listen to multiple databases at the same time? #166

slowside45 opened this issue Apr 11, 2025 · 3 comments

Comments

@slowside45
Copy link

slowside45 commented Apr 11, 2025

I created two threads and set BinaryLogClient's object as :
binaryClient.setBlocking(false); ..................... binaryClient.connect(5000);

then I start those two sub threads at the same time in the main thread, but only the first thread can listened the event

@osheroff
Copy link
Owner

I'm not totally sure what you're trying to do. Post some sample
Code?

@slowside45
Copy link
Author

slowside45 commented May 6, 2025

There are many databases in my product environment, I need to listen all of these databases, their host, port, databaseName are different, so I have to create some BinarylogClients, every BinaryLogClient has a BinlogListener, then to listen the databases. Now I create these BinaryLogClients in different threads, it can be started and listener can connect to those databases successfully, but after listener do onEvent() once, the keepAliveThread will be shutdown, then I can't receive any databases event message anymore. the logs is like this:

16:31:38:793 INFO com.github.shyiko.mysql.binlog.BinaryLogClient - Connected to xxxxxx at binlog.000012/955973598 (cid:9704)
.......................(something like event message)
16:31:38:826 INFO com.github.shyiko.mysql.binlog.BinaryLogClient - threadExecutor is shut down, terminating keepalive thread

My question is What should I do when I'm trying to create BinaryLogClient? Or is there any property need to be setup?(keepAlive/blocking/or any else could be useful)

@slowside45
Copy link
Author

slowside45 commented May 6, 2025

I found when the springboot application is running, I can create many BinaryLogClients in different thread successfully, and they will never disconnected, the keepalive thread won't be terminated and I can receive database event message. But after I restart my springboot application, console will print logs like this:

16:31:38:793 INFO com.github.shyiko.mysql.binlog.BinaryLogClient - Connected to xxxxxx at binlog.000012/955973598 (cid:9704)
........................(something like event message)
16:31:38:826 INFO com.github.shyiko.mysql.binlog.BinaryLogClient - threadExecutor is shut down, terminating keepalive thread

then the keepalive thread will be terminated, and then I can't receive any databse event message anymore.

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