easycanal


License

License

GroupId

GroupId

com.github.lzj960515
ArtifactId

ArtifactId

easycanal
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom
Description

Description

easycanal
easycanal
Project URL

Project URL

https://github.com/lzj960515/easycanal
Source Code Management

Source Code Management

https://github.com/lzj960515/easycanal.git

Download easycanal

Filename Size
easycanal-1.0.1.pom 6 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lzj960515/easycanal/ -->
<dependency>
    <groupId>com.github.lzj960515</groupId>
    <artifactId>easycanal</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.lzj960515/easycanal/
implementation 'com.github.lzj960515:easycanal:1.0.1'
// https://jarcasting.com/artifacts/com.github.lzj960515/easycanal/
implementation ("com.github.lzj960515:easycanal:1.0.1")
'com.github.lzj960515:easycanal:pom:1.0.1'
<dependency org="com.github.lzj960515" name="easycanal" rev="1.0.1">
  <artifact name="easycanal" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.lzj960515', module='easycanal', version='1.0.1')
)
libraryDependencies += "com.github.lzj960515" % "easycanal" % "1.0.1"
[com.github.lzj960515/easycanal "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • easycanal-core
  • easycanal-samples
  • easycanal-spring-boot-starter

easycanal

简化canal的使用方式,集成Spring, 只需加上配置与相应的注解,即可像MQ一样使用canal

使用方式

  • starter方式

    • 引入easycanal-spring-boot-starter依赖

       <dependency>
              <groupId>com.github.lzj960515</groupId>
              <artifactId>easycanal-spring-boot-starter</artifactId>
              <version>1.0.1</version>
       </dependency>
    • 编写配置

       canal:
         server:
           host: 127.0.0.1
           port: 11111
           destination: example
           username: canal
           password: canal 
    • 在使用的方法上加上@OnCanalMessage注解

          @Service
          public class DemoService {
          
              @OnCanalMessage(schemaName = "test", tableName = "fruit", id = "id", eventType = EventType.INSERT)
              public void onInsertMessage(CanalMessage canalMessage){
                  System.out.println("监听到表test.fruit插入");
                  Map<String, String> allColumn = canalMessage.getAllColumn();
                  Map<String, String> onlyUpdateColumn = canalMessage.getOnlyUpdateColumn();
                  System.out.println("所有列:" + allColumn);
                  System.out.println("更新了的列" + onlyUpdateColumn);
              }
          }

      schemaName: 数据库名
      tableName: 表名
      id: 表的主键
      eventType: 事件类型

Versions

Version
1.0.1
1.0.0