Comments (8)
I did this in two parts:
- Attach a lifecycle listener that implements onConnect() and grabs the initial binlog filename from the client. This gets you the initial binlog filename.
- Handle the rotate event, which will tell you the filename of the next binlog.
from mysql-binlog-connector-java.
That sounds good, thanks!
from mysql-binlog-connector-java.
@ducaddepar @wushujames For the record, you can get it from BinaryLogClient::getBinlogFilename(). Its value changes with each incoming event.
from mysql-binlog-connector-java.
@shyiko Oh right, that's definitely the way to go if you have a reference to the BinaryLogClient. I had assumed @ducaddepar was asking about getting it within the context of an EventListener, where it's normally not exposed to you.
You bring up a good point tho. You could simply pass your BinaryLogClient to the EventListener, and grab the filename that way. That way, you don't need to handle ROTATE events.
from mysql-binlog-connector-java.
I was asking because it's unclear if BinaryLogClient getBinLogFileName() is thread-safe to access during onEvent(). But looks like it should be since the binary log client runs in one thread. Is that right?
from mysql-binlog-connector-java.
Both binlogFilename
& binlogPosition
are marked volatile
;)
from mysql-binlog-connector-java.
I think marking them volatile not necessarily make binlogFilename return the corresponding binlog file name of the event. If the client processes the binlog in two threads, while thread 1's onEvent() is invoked, thread 2 may modify binlogFilename, and so accessing binlogFilename in thread 1's onEvent() gives an inaccurate value.
from mysql-binlog-connector-java.
EventListeners are getting called in the same thread BinaryLogClient listens in, meaning you don't have to worry about thread safety unless you grab that piece of information from another thread (like through JMX). Because there is no point in setting a different binlogFilename other than before connect
(in which case BinaryLogClient should not be running, thus no onEvent() can be called at this time) volatile does provide enough (visible reads) guarantee.
NOTE: BinaryLogClient either uses the same thread it was connect
ed in or a separate one in case of connect(timeout)
. There are no other threads (except for a "keep alive" thread).
from mysql-binlog-connector-java.
Related Issues (20)
- NPE in TableMapEvent deserialization continuously HOT 1
- exception occured when i use function [JsonBinary.parseAsString]
- com.github.shyiko.mysql.binlog.network.AuthenticationException: Client does not support authentication protocol requested by server; consider upgrading MySQL client HOT 5
- ByteArrayInputStream has a performance problem HOT 2
- No break keyword in the switch-case code block.
- How to get only the binlog that listens to the specified db database HOT 1
- Is there any performance test report?
- BinaryLogClient auto detects wrongly MariaDB instead of MySQL HOT 1
- I want to get all the columns instead of filtering out the columns with a null value
- readMetadata HOT 1
- Provide ability to specify JDBC connection string HOT 1
- Failed to execute CommandLineRunner
- disconnect call getting blocked with keepalive thread
- [AWS Aurora] com.github.shyiko.mysql.binlog.network.AuthenticationException: unsupported authentication method: mysql_clear_password
- How to solve the binlog sync delay?
- The ROTATE event gets the wrong position
- Wrong value for time(6) data type
- Failed to deserialize data of EventHeaderV4
- [v0.25.3] Failed to deserialize data of EventHeaderV4. Possible fixes included.
- 字段类似是longtext,eventData.getRows()返回的是个地址
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mysql-binlog-connector-java.