1 概述
mysql、MongoDB数据变动监听分发
本项目意在简化监听mysql、MongoDB数据库的不同表的各种数据变动
项目依赖redis,mysql
使用场景:刷新缓存、异构系统...
2 使用方式
从bin-log-distributor-app到client数据分发方式的默认实现为redis,如果要开发基于其他的比如mq,只需要分别实现bin-log-distributor-pub下的DataPublisher接口与bin-log-distributor-client下的即可
2.1 服务端
服务端是项目中bin-log-distributor-app模块,在mysql-binlog-connector-java基础上提供了监听mysql数据库二进制日志并进行分发的功能
2.1.1 参考配置
# redis地址
spring.redisson.address=redis://192.168.1.204:6379
# mysql日志同步账户,
binaryLog.host = 192.168.1.204
binaryLog.port = 3306
binaryLog.username = aa
binaryLog.password = aa
binaryLog.serverId = 1
# 读取列名,进行映射
spring.datasource.url = jdbc:mysql://${binaryLog.host}:${binaryLog.port}/mysql?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
spring.datasource.username = ${binaryLog.username}
spring.datasource.password = ${binaryLog.password}
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# rabbitmq连接相关信息(如果只有redis客户端可以不需要使用)
spring.rabbit.host = 192.168.1.204
spring.rabbit.port = 5672
spring.rabbit.username = aa
spring.rabbit.password = aa
spring.rabbit.virtualHost = /binlog
2.1.2