update 2021年11月2日15:30:01
parent
225105d799
commit
9efdad7fc9
|
|
@ -12,42 +12,13 @@ import com.xpand.starter.canal.annotation.*;
|
||||||
public class CanalDataEventListener {
|
public class CanalDataEventListener {
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 增加数据监听
|
* 自定义数据修改监听 @ListenPoint @InsertListenPoint @UpdateListenPoint @DeleteListenPoint
|
||||||
* @param eventType
|
* @param eventType
|
||||||
* @param rowData
|
* @param rowData
|
||||||
*/
|
*/
|
||||||
@InsertListenPoint
|
@ListenPoint(destination = "example", schema = "mystyle-blog")
|
||||||
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)
|
|
||||||
public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
|
public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
|
||||||
System.err.println("QUERY");
|
System.err.println(CanalEntry.EventType.valueOf(eventType.getNumber()));
|
||||||
rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " :: " + c.getValue()));
|
rowData.getAfterColumnsList().forEach((c) -> System.out.println("row: " + c.getName() + " :: " + c.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,6 @@ canal:
|
||||||
instances:
|
instances:
|
||||||
example:
|
example:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 3306
|
port: 11111
|
||||||
userName: canal
|
userName: canal
|
||||||
password: root
|
password: canal
|
||||||
Loading…
Reference in New Issue