update 2021年11月2日15:30:01
parent
225105d799
commit
9efdad7fc9
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ canal:
|
|||
instances:
|
||||
example:
|
||||
host: 127.0.0.1
|
||||
port: 3306
|
||||
port: 11111
|
||||
userName: canal
|
||||
password: root
|
||||
password: canal
|
||||
Loading…
Reference in New Issue