All Projects → NormanGyllenhaal → canal-client

NormanGyllenhaal / canal-client

Licence: other
spring boot canal starter 易用的canal 客户端 canal client

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to canal-client

Gpmall
【咕泡学院实战项目】-基于SpringBoot+Dubbo构建的电商平台-微服务架构、商城、电商、微服务、高并发、kafka、Elasticsearch
Stars: ✭ 4,241 (+3162.31%)
Mutual labels:  springboot, canal
active4j
Active4j-boot是基于SpingBoot2.0轻量级的java快速开发框架。以Spring Framework为核心容器,Spring MVC为模型视图控制器,Mybatis Plus为数据访问层, Apache Shiro为权限授权层, Redis为分布式缓存,Quartz为分布式集群调度,layui作为前端框架并进行前后端分离的开源框架
Stars: ✭ 32 (-75.38%)
Mutual labels:  springboot
file management sys
file_management_sys 是一个文件共享系统,包括前端文件展示系统和后台管理系统,基于SpringBoot + MyBatis实现。前端文件展示系统包括文件分类和展示界面,文件搜索和文件上传等模块。后台管理系统包含文件管理,权限管理等模块。
Stars: ✭ 60 (-53.85%)
Mutual labels:  springboot
mzt-biz-log
支持Springboot,基于注解的可使用变量、可以自定义函数的通用操作日志组件
Stars: ✭ 628 (+383.08%)
Mutual labels:  springboot
Online-Testing-Platform
在线考试系统 colleges online examination system base on spring-boot and MyBatis
Stars: ✭ 21 (-83.85%)
Mutual labels:  springboot
permission
前后端分离的后台权限管理系统,基于Spring Boot, Shiro, Vue, Element实现,预览地址http://123.206.82.234/#/login
Stars: ✭ 44 (-66.15%)
Mutual labels:  springboot
BookRecommenderSystem
基于大数据的图书推荐系统
Stars: ✭ 30 (-76.92%)
Mutual labels:  springboot
smart-cloud-examples
基于springcloud的脚手架(smart-cloud)示例,支持服务合并部署与拆分部署、接口加解密签名、日志数据脱敏、接口数据mock、接口文档自动生成、请求幂等校验、接口日志&&sql日志切面打印、分表分库分布式事务等
Stars: ✭ 23 (-82.31%)
Mutual labels:  springboot
Keyist-Ecommerce
🔑 A simple ecommerce site powered with Spring Boot + Angular 10 + Ngrx + OAuth2
Stars: ✭ 220 (+69.23%)
Mutual labels:  springboot
canal-client
针对阿里巴巴 canal客户端封装,与spring无缝衔接
Stars: ✭ 25 (-80.77%)
Mutual labels:  canal-client
agile-wroking-backend
AgileWorking 是一个团队协作的微信小程序,此工程为小程序的后台实现
Stars: ✭ 67 (-48.46%)
Mutual labels:  springboot
angular-springboot-demo
旅馆管理系统
Stars: ✭ 91 (-30%)
Mutual labels:  springboot
netty-learning
bio, nio到 netty各种使用案例, 包含基础使用案例,各api使用方法,零拷贝,websocket,群聊,私聊,编码,解码,自定义协议,protobuf等使用案例,rpc服务器,客户端等等学习
Stars: ✭ 49 (-62.31%)
Mutual labels:  springboot
job-plus
Job Plus项目是基于SpringBoot+Vue的轻量级定时任务管理系统
Stars: ✭ 17 (-86.92%)
Mutual labels:  springboot
SecExample
JAVA 漏洞靶场 (Vulnerability Environment For Java)
Stars: ✭ 228 (+75.38%)
Mutual labels:  springboot
NeusoftCloudHospital
东软云医院。爱与健康,连接你我。🏥
Stars: ✭ 37 (-71.54%)
Mutual labels:  springboot
learn-java-demo
java学习demo
Stars: ✭ 17 (-86.92%)
Mutual labels:  springboot
subtitles-view
基于javaFX的简单字幕处理桌面程序,集成在线翻译及语音转换
Stars: ✭ 368 (+183.08%)
Mutual labels:  springboot
compose-pay
🔱 HA distributed payment gateway. 高可用分布式支付网关/支付前置/支付系统/微信/支付宝
Stars: ✭ 21 (-83.85%)
Mutual labels:  springboot
spring-security-passwordless
Passwordless authentication example application using Spring Boot and Spring Security
Stars: ✭ 112 (-13.85%)
Mutual labels:  springboot

Build Status

易用的canal 客户端 easy canal client

介绍

canal 是阿里巴巴mysql数据库binlog的增量订阅&消费组件
使用该客户端前请先了解canal,https://github.com/alibaba/canal
canal 自身提供了简单的客户端,如果要转换为数据库的实体对象,处理消费数据要每次进行对象转换。 该客户端直接将canal的数据原始类型转换为各个数据表的实体对象,并解耦数据的增删改操作,方便给业务使用。

要求

java8+

特性

  • 解耦单表增删操作
  • simple,cluster,zookeeper,kafka客户端支持
  • 同步异步处理支持
  • spring boot 开箱即用

如何使用

spring boot 方式 maven 依赖

  <dependency>
      <groupId>top.javatool</groupId>
      <artifactId>canal-spring-boot-starter</artifactId>
      <version>1.2.6-RELEASE</version>
  </dependency>

java 方式

 <dependency>
       <groupId>top.javatool</groupId>
       <artifactId>canal-client</artifactId>
       <version>1.2.6-RELEASE</version>
 </dependency>

配置说明

属性 描述 默认值
canal.mode canal 客户端类型 目前支持4种类型 simple,cluster,zk,kafka(kafka 目前支持flatMessage 格式) simple
canal.filter canal过滤的表名称,如配置则只订阅配置的表 ""
canal.batch-size 消息的数量,超过该次数将进行一次消费 1(个)
canal.timeout 消费的时间间隔(s) 1s
canal.server 服务地址,多个地址以,分隔 格式 ${host}:${port} null
canal.destination canal 的instance 名称,kafka模式为topic 名称 null
canal.user-name canal 的用户名 null
canal.password canal 的密码 null
canal.group-id kafka groupId 消费者订阅消息时可使用,kafka canal 客户端 null
canal.async 是否是异步消费,异步消费时,消费时异常将导致消息不会回滚,也不保证顺序性 true
canal.partition kafka partition null

订阅数据库的增删改操作

实现EntryHandler 接口,泛型为想要订阅的数据库表的实体对象, 该接口的方法为 java 8 的 default 方法,方法可以不实现,如果只要监听增加操作,只实现增加方法即可
下面以一个t_user表的user实体对象为例, 默认情况下,将使用实体对象的jpa 注解 @Table中的表名来转换为EntryHandler中的泛型对象,

public class UserHandler implements EntryHandler<User>{

}

如果实体类没有使用jpa @Table的注解,也可以使用@CanalTable 注解在EntryHandler来标记表名,例如

@CanalTable(value = "t_user")
@Component
public class UserHandler implements EntryHandler<User>{

   /**
   *  新增操作
   * @param user
    */
   @Override
    public void insert(User user) {
	   //你的逻辑
        log.info("新增 {}",user);
    }
    /**
    * 对于更新操作来讲,before 中的属性只包含变更的属性,after 包含所有属性,通过对比可发现那些属性更新了
   * @param before
   * @param after
    */
    @Override
    public void update(User before, User after) {
    	//你的逻辑
        log.info("更新 {} {}",before,after);
    }
    /**
    *  删除操作
    * @param user
    */
    @Override
    public void delete(User user) {
       //你的逻辑
        log.info("删除 {}",user); 
   }
}

另外也支持统一的处理@CanalTable(value="all"),这样除去存在EntryHandler的表以外,其他所有表的处理将通过该处理器,统一转为Map<String, String>对象

@CanalTable(value = "all")
@Component
public class DefaultEntryHandler implements EntryHandler<Map<String, String>> {
     @Override
        public void insert(Map<String, String> map) {
            logger.info("insert message  {}", map);
        }
    
        @Override
        public void update(Map<String, String> before, Map<String, String> after) {
            logger.info("update before {} ", before);
            logger.info("update after {}", after);
        }
    
        @Override
        public void delete(Map<String, String> map) {
            logger.info("delete  {}", map);
        }
}

如果你想获取除实体类信息外的其他信息,可以使用

CanalModel canal = CanalContext.getModel();

具体使用可以查询项目demo 示例
https://github.com/NormanGyllenhaal/canal-client/tree/master/canal-example

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].