update 2021年11月2日15:30:01

master
zhangmeng 2021-11-02 15:30:08 +08:00
parent 225105d799
commit 9efdad7fc9
2 changed files with 6 additions and 35 deletions

View File

@ -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()));
}
}

View File

@ -21,6 +21,6 @@ canal:
instances:
example:
host: 127.0.0.1
port: 3306
port: 11111
userName: canal
password: root
password: canal