diff --git a/mystyle-cloud-canal/src/main/java/com/zhangmeng/canal/listener/CanalDataEventListener.java b/mystyle-cloud-canal/src/main/java/com/zhangmeng/canal/listener/CanalDataEventListener.java index 267b65e..278d8de 100644 --- a/mystyle-cloud-canal/src/main/java/com/zhangmeng/canal/listener/CanalDataEventListener.java +++ b/mystyle-cloud-canal/src/main/java/com/zhangmeng/canal/listener/CanalDataEventListener.java @@ -12,42 +12,13 @@ import com.xpand.starter.canal.annotation.*; public class CanalDataEventListener { /*** - * 增加数据监听 + * 自定义数据修改监听 @ListenPoint @InsertListenPoint @UpdateListenPoint @DeleteListenPoint * @param eventType * @param rowData */ - @InsertListenPoint - public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " :: " + c.getValue())); - } - - /*** - * 修改数据监听 - * @param rowData - */ - @UpdateListenPoint - public void onEventUpdate(CanalEntry.RowData rowData) { - System.out.println("UpdateListenPoint"); - rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " :: " + c.getValue())); - } - - /*** - * 删除数据监听 - * @param eventType - */ - @DeleteListenPoint - public void onEventDelete(CanalEntry.EventType eventType) { - System.out.println("DeleteListenPoint"); - } - - /*** - * 自定义数据修改监听 - * @param eventType - * @param rowData - */ - @ListenPoint(destination = "example", schema = "mystyle-blog", table = {"user", "role"}, eventType = CanalEntry.EventType.QUERY) + @ListenPoint(destination = "example", schema = "mystyle-blog") public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - System.err.println("QUERY"); - rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " :: " + c.getValue())); + System.err.println(CanalEntry.EventType.valueOf(eventType.getNumber())); + rowData.getAfterColumnsList().forEach((c) -> System.out.println("row: " + c.getName() + " :: " + c.getValue())); } } diff --git a/mystyle-cloud-canal/src/main/resources/application.yml b/mystyle-cloud-canal/src/main/resources/application.yml index f35ddb7..b6e96b1 100644 --- a/mystyle-cloud-canal/src/main/resources/application.yml +++ b/mystyle-cloud-canal/src/main/resources/application.yml @@ -21,6 +21,6 @@ canal: instances: example: host: 127.0.0.1 - port: 3306 + port: 11111 userName: canal - password: root \ No newline at end of file + password: canal \ No newline at end of file