All Projects → kekingcn → Kkbinlog

kekingcn / Kkbinlog

Licence: apache-2.0
支持mysql、MongoDB数据变更订阅分发

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Kkbinlog

Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+48825.89%)
Mutual labels:  mysql, mongodb, spring-boot, spring, rabbitmq
Spring Boot Vue Bank
我,请始皇[打钱]是一个前后端分离的工具人系统,项目采用 SpringBoot+Go+Vue 开发,项目加入常见的企业级应用所涉及到的技术点,例如 Redis、RabbitMQ 等(主要是多用用工具多踩踩坑)。
Stars: ✭ 157 (+40.18%)
Mutual labels:  kafka, mysql, mongodb, spring
Docker Compose
一些基础服务的docker-compose配置文件,方便在一台新电脑上快速开始工作
Stars: ✭ 163 (+45.54%)
Mutual labels:  mysql, mongodb, etcd, rabbitmq
Cookbook
🎉🎉🎉JAVA高级架构师技术栈==任何技能通过 “刻意练习” 都可以达到融会贯通的境界,就像烹饪一样,这里有一份JAVA开发技术手册,只需要增加自己练习的次数。🏃🏃🏃
Stars: ✭ 428 (+282.14%)
Mutual labels:  kafka, mysql, spring-boot, rabbitmq
Superman
Superman是什么:构建Java 高级开发技术的知识体系,从基础不断打怪升级成为超人之路(更新中.......)
Stars: ✭ 106 (-5.36%)
Mutual labels:  kafka, spring-boot, spring, rabbitmq
Springboot Templates
springboot和dubbo、netty的集成,redis mongodb的nosql模板, kafka rocketmq rabbit的MQ模板, solr solrcloud elasticsearch查询引擎
Stars: ✭ 100 (-10.71%)
Mutual labels:  kafka, mongodb, spring-boot, rabbitmq
Full Stack Notes
全栈工程师手册
Stars: ✭ 366 (+226.79%)
Mutual labels:  kafka, mysql, mongodb, rabbitmq
Spring Boot Demo
Spring Boot & Spring Cloud & Spring Security Demo Case(Spring学习示例实战项目)
Stars: ✭ 255 (+127.68%)
Mutual labels:  mysql, mongodb, spring-boot, spring
Books Recommendation
程序员进阶书籍(视频),持续更新(Programmer Books)
Stars: ✭ 558 (+398.21%)
Mutual labels:  kafka, mysql, spring-boot, spring
All Things Cqrs
Comprehensive guide to a couple of possible ways of synchronizing two states with Spring tools. Synchronization is shown by separating command and queries in a simple CQRS application.
Stars: ✭ 474 (+323.21%)
Mutual labels:  kafka, mongodb, spring-boot, spring
Testcontainers Spring Boot
Container auto-configurations for spring-boot based integration tests
Stars: ✭ 460 (+310.71%)
Mutual labels:  kafka, mongodb, spring-boot, rabbitmq
Springbootunity
rabbitmq、redis、scheduled、socket、mongodb、Swagger2、spring data jpa、Thymeleaf、freemarker etc. (muti module spring boot project) (with spring boot framework,different bussiness scence with different technology。)
Stars: ✭ 845 (+654.46%)
Mutual labels:  mysql, mongodb, spring-boot, spring
Spring Boot Examples
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。
Stars: ✭ 26,812 (+23839.29%)
Mutual labels:  mongodb, spring-boot, spring, rabbitmq
Spring Boot 2.x Examples
Spring Boot 2.x code examples
Stars: ✭ 104 (-7.14%)
Mutual labels:  kafka, mysql, mongodb, spring-boot
Illuminati
This is a Platform that collects all the data accuring in your Application and shows the data in real time by using Kibana or other tools.
Stars: ✭ 106 (-5.36%)
Mutual labels:  kafka, spring, rabbitmq
Webfluxtemplate
Spring Webflux template application with working Spring Security, Web-sockets, Rest, Web MVC, and Authentication with JWT.
Stars: ✭ 107 (-4.46%)
Mutual labels:  mongodb, spring-boot, spring
Phalcon Vm
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.
Stars: ✭ 43 (-61.61%)
Mutual labels:  mysql, mongodb, rabbitmq
Flink Learning
flink learning blog. http://www.54tianzhisheng.cn/ 含 Flink 入门、概念、原理、实战、性能调优、源码解析等内容。涉及 Flink Connector、Metrics、Library、DataStream API、Table API & SQL 等内容的学习案例,还有 Flink 落地应用的大型项目案例(PVUV、日志存储、百亿数据实时去重、监控告警)分享。欢迎大家支持我的专栏《大数据实时计算引擎 Flink 实战与性能优化》
Stars: ✭ 11,378 (+10058.93%)
Mutual labels:  kafka, mysql, rabbitmq
Springboot Labs
一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024
Stars: ✭ 12,804 (+11332.14%)
Mutual labels:  kafka, spring-boot, rabbitmq
Web Development Interview With Java
Java 开发相关技术栈(大中厂)高频面试问题收录。
Stars: ✭ 69 (-38.39%)
Mutual labels:  mysql, spring-boot, spring

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 启动方式

编译打包项目,直接通过(java -jar)启动bin-log-distributor-app-${version}-SNAPSHOT.jar,可参考spring boot手册

2.2 客户端

2.2.1 redis客户端

2.2.1.1 引入依赖包

<dependency>
    <groupId>cn.keking.project</groupId>
    <artifactId>bin-log-distributor-client-redis</artifactId>
    <version>${version}</version>
</dependency>

2.2.1.2 添加客户端配置

#自动注册客户端(2.1中服务端的地址)
databaseEventServerUrl=http://localhost:8885/client/addAll
#本应用命名
appName=lbt-service-ext-redis
# redis地址
spring.redisson.address=redis://192.168.1.204:6379

2.2.1.3 写handler,实现 DatabaseEventHandler 接口,并加上注解 @HandleDatabaseEven

/**
 * LockLevel为保持顺序的级别,None为默认
 * TABLE -> 同表按顺序执行
 * COLUMN -> 某列值一致的按顺序执行
 * NONE -> 无序
 */
@Service
@HandleDatabaseEvent(database = "Rana_G", table = "PTP_PROJ_REP_HIS", events = {DatabaseEvent.UPDATE_ROWS, DatabaseEvent.DELETE_ROWS},lockLevel = LockLevel.TABLE)
public class ProjRepHisDatabaseEventHandler implements DatabaseEventHandler {
    private static final Logger logger = LoggerFactory.getLogger(ProjRepHisDatabaseEventHandler.class);

    @Override
    public void handle(EventBaseDTO eventBaseDTO) {
        logger.info(JSON.toJSONString(eventBaseDTO));
        // todo 在这里写相关逻辑
    }
}

2.2.1.4 启动监听,当2里的handler是由容器管理时需要通过registerHandler(projRepHisDatabaseEventHandler)手动注册,如果不需要容器管理,可以直接通过autoScanHandler()自动扫描添加

@Component
public class DatabaseEventListener {
    private static Logger logger = LoggerFactory.getLogger(DatabaseEventListener.class);
    
    @Autowired
    private RedissonClient redissonClient;

    @Value("#{env.databaseEventServerUrl}")
    private String serverUrl;
    
    @Value("#{env.appName}")
    private String appName;
    
    //将第3步里的service注入
    @Autowired
    private ProjRepHisDatabaseEventHandler projRepHisDatabaseEventHandler; 

    @PostConstruct
    public void start() {
        //初始化订阅的实现
        DataSubscriber dataSubscriber = new DataSubscriberRedisImpl(redissonClient);
        new BinLogDistributorClient(appName, dataSubscriber)
                //在binlog中注册handler
                .setQueueType(ClientInfo.QUEUE_TYPE_REDIS) 
                .registerHandler(projRepHisDatabaseEventHandler)
                .setServerUrl(serverUrl).autoRegisterClient().start();
    }
}

2.2.2 rabbitmq客户端

2.2.2.1 引入依赖包

<dependency>
    <groupId>cn.keking.project</groupId>
    <artifactId>bin-log-distributor-client-rabbitmq</artifactId>
    <version>${version}</version>
</dependency>

2.2.2.2 添加客户端配置

#自动注册客户端(2.1中服务端的地址)
databaseEventServerUrl=http://localhost:8885/client/addAll
#本应用命名
appName=lbt-service-ext-rabbit
# redis地址(rabbitmq实现也要使用redis作为分布式锁)
spring.redisson.address=redis://192.168.1.204:6379
# RabbitMQ配置
spring.rabbit.host=192.168.1.204
spring.rabbit.port=5672
spring.rabbit.username=aa
spring.rabbit.password=aa
spring.rabbit.virtualHost=/binlog
spring.rabbit.apiUrl=http://192.168.1.204:15672/api/

2.2.2.3 写handler,实现 DatabaseEventHandler 接口,并加上注解 @HandleDatabaseEven

/**
 * LockLevel为保持顺序的级别,None为默认
 * TABLE -> 同表按顺序执行
 * COLUMN -> 某列值一致的按顺序执行
 * NONE -> 无序
 */
@Service
@HandleDatabaseEvent(database = "Rana_G", table = "PTP_PROJ_REP_HIS", events = {DatabaseEvent.UPDATE_ROWS, DatabaseEvent.DELETE_ROWS},lockLevel = LockLevel.TABLE)
public class ProjRepHisDatabaseEventHandler implements DatabaseEventHandler {
    private static final Logger logger = LoggerFactory.getLogger(ProjRepHisDatabaseEventHandler.class);

    @Override
    public void handle(EventBaseDTO eventBaseDTO) {
        logger.info(JSON.toJSONString(eventBaseDTO));
        // todo 在这里写相关逻辑
    }
}

2.2.2.4 启动监听,当2里的handler是由容器管理时需要通过registerHandler(projRepHisDatabaseEventHandler)手动注册,如果不需要容器管理,可以直接通过autoScanHandler()自动扫描添加

@Component
public class DatabaseEventListener {
    private static Logger logger = LoggerFactory.getLogger(DatabaseEventListener.class);
    
    @Autowired
    private RedissonClient redissonClient;

    @Value("#{env.databaseEventServerUrl}")
    private String serverUrl;
    
    @Value("#{env.appName}")
    private String appName;
    //将第3步里的service注入
    
    @Autowired
    private ProjRepHisDatabaseEventHandler projRepHisDatabaseEventHandler; 
    
    //org.springframework.amqp.rabbit.connection.ConnectionFactory 自行创建spring bean
    @Autowired
    private ConnectionFactory connectionFactory; 

    //com.rabbitmq.http.client.Client 自行创建spring bean
    @Autowired
    private Client rabbitHttpClient; 

    @PostConstruct
    public void start() {
        //初始化订阅的实现
        DataSubscriber dataSubscriber = new DataSubscriberRabbitMQImpl(connectionFactory, rabbitHttpClient, redissonClient);
        new BinLogDistributorClient(appName, dataSubscriber)
                //默认为redis实现,使用mq实现这里一定要指定QueueType
                .setQueueType(ClientInfo.QUEUE_TYPE_RABBIT)
                .registerHandler(projRepHisDatabaseEventHandler)
                .setServerUrl(serverUrl).autoRegisterClient().start();
    }
}

2.3 前端管理模块

前端管理服务模块是基于vue的管理各个应用监听状况的管理界面

新增MySQL数据源

数据源管理

日志进度

分发队列监控

新增数据订阅

3 其他

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].