Binlog4j 1.2.0 发布,Java 轻量级 Binary Log 客户端

Binlog4j

轻量级 Mysql Binlog 客户端, 提供宕机续读, 高可用集群等特性

项目特性

更新日志(1.2.0)

[新增] BinlogClient 类 connect 方法日志打印。 [新增] Binlog4jException.class 代替 RuntimeException.class 异常处理。 [新增] binlog4j-spring-boot-starter 包 spring.binlog4j.enabled 配置, 默认为 true。 [新增] GsonUtils 工具类到 utils 包 , 提供 Gson 方法。 [升级] spring-boot 到 2.7.14 版本。 [升级] redisson 到 3.23.3 版本。 [升级] gson 到 2.10.1 版本。 [升级] jedis 到 4.4.3 版本

下载安装

简单使用

通过 BinlogClient 创建 binlog 客户端, IBinlogEventHandler 用于接受 binlog 事件通知, 该接口允许使用泛型, 数据将遵循驼峰规则进行封装。

高级特性

通过 Persistence 配置为 true 启用宕机续读功能, Binlog4j 会将 binlog 的 filename 与 position 记录到 redis, 所以同时你需要设置 Redis 配置。

Spring Boot Starter

首先, 在 application.yml 中填写 BinlogClient 配置

单表监听

使用 @BinlogSubscriber 注解, 指定 IBinlogEventHandler 需要注册到哪个客户端, 并且指定监听的 database 与 table。

多表监听

@BinlogSubscriber 注解 database 与 table 属性支持 Pattern 匹配, IBinlogEventHandler 在不指定泛型的情况下, event.getData() 为 Map<String, Object> 类型, 用于兼容不同表的数据结构。

监听 master 数据源所有数据库中所有表的数据变化【最灵活】

监听 master 数据源 pear-admin 数据库中所有表的数据变化

监听 master 数据源 pear-admin 数据库中 user 表的数据变化

监听 master 数据源所有数据库中 user 表的数据变化

监听 master 数据源所有数据库中以 user 开头的表的数据变化

未经允许不得转载:岩猫星空网 » Binlog4j 1.2.0 发布,Java 轻量级 Binary Log 客户端