osheroff / mysql-binlog-connector-java

MySQL Binary Log connector
641 stars 161 forks source link

方法updateClientBinlogFilenameAndPosition和updateGtidSet等方法一样,可以被按需重写 #145

Open xzxiaoshan opened 2 months ago

xzxiaoshan commented 2 months ago

方法updateClientBinlogFilenameAndPosition和updateGtidSet等方法一样,可以被按需重写。 例如,重写该方法并添加对 binlogFileName 和 position 进行持久化。当服务宕机重启后可以从持久化中读取并继续。

例如:

        BinaryLogClient client = new BinaryLogClient(binLogProperties.getHost(), binLogProperties.getPort(),
                binLogProperties.getUsername(), binLogProperties.getPassword()) {

            @Override
            private void updateClientBinlogFilenameAndPosition(Event event) {
                super.updateClientBinlogFilenameAndPosition(event);
                // 将binlogFileName和position持久化记录,在服务宕机重启后读取并继续
                // (略)
            }
        };