From a8f947d2bc621051821e0cc57335aa6ca1776a8e Mon Sep 17 00:00:00 2001
From: duxinglangzi <871364441@qq.com>
Date: 星期四, 04 八月 2022 18:16:29 +0800
Subject: [PATCH] 修改启用方式为EnableCanalListener注解 修改重试次数瑕疵

---
 README.md |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index 30e716e..706c80c 100644
--- a/README.md
+++ b/README.md
@@ -22,13 +22,15 @@
 
 ```
 
-### 鍦╯pring boot 椤圭洰涓殑浠g爜浣跨敤瀹炰緥 
+### 鍦╯pring boot 椤圭洰涓殑浠g爜浣跨敤瀹炰緥 (娉ㄦ剰闇�瑕佷娇鐢� EnableCanalListener 娉ㄨВ寮�鍚� canal listener )
+
 ```java
 
 
 import com.alibaba.otter.canal.protocol.CanalEntry;
 import com.duxinglangzi.canal.starter.annotation.CanalListener;
 import com.duxinglangzi.canal.starter.annotation.CanalUpdateListener;
+import com.duxinglangzi.canal.starter.annotation.EnableCanalListener;
 import org.springframework.stereotype.Service;
 
 import java.util.stream.Collectors;
@@ -37,14 +39,17 @@
  * @author wuqiong 2022/4/12
  * @description
  */
+@EnableCanalListener
 @Service
 public class CanalListenerTest {
 
     /**
+     * 蹇呴』鍦ㄧ被涓� 浣跨敤 EnableCanalListener 娉ㄨВ鎵嶈兘寮�鍚� canal listener 
+     * 
      * 鐩墠 Listener 鏂规硶鐨勫弬鏁板繀椤讳负 CanalEntry.EventType , CanalEntry.RowData 
      * 绋嬪簭鍦ㄥ惎鍔ㄨ繃绋嬩腑浼氬仛妫�鏌�
      */
-    
+
     /**
      * 鐩戞帶鏇存柊鎿嶄綔
      * 鏀寔鍔ㄦ�佸弬鏁伴厤缃紝閰嶇疆椤归渶鍦� yml 鎴� properties 杩涜閰嶇疆
@@ -52,7 +57,7 @@
      */
     @CanalUpdateListener(destination = "${prod.example}", database = "${prod.database}", table = {"users"})
     public void listenerExampleBooksUsers(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerExampleBooksUsers",eventType, rowData);
+        printChange("listenerExampleBooksUsers", eventType, rowData);
     }
 
     /**
@@ -60,7 +65,7 @@
      */
     @CanalUpdateListener(destination = "example", database = "books", table = {"users"})
     public void listenerExampleBooksUsers(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerExampleBooksUsers",eventType, rowData);
+        printChange("listenerExampleBooksUsers", eventType, rowData);
     }
 
     /**
@@ -68,7 +73,7 @@
      */
     @CanalUpdateListener(destination = "example", database = "books", table = {"books"})
     public void listenerExampleBooksBooks(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerExampleBooksBooks",eventType, rowData);
+        printChange("listenerExampleBooksBooks", eventType, rowData);
     }
 
     /**
@@ -76,7 +81,7 @@
      */
     @CanalListener(destination = "example", database = "books", eventType = CanalEntry.EventType.UPDATE)
     public void listenerExampleBooksAll(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerExampleBooksAll",eventType, rowData);
+        printChange("listenerExampleBooksAll", eventType, rowData);
     }
 
     /**
@@ -84,7 +89,7 @@
      */
     @CanalListener(destination = "example", eventType = CanalEntry.EventType.UPDATE)
     public void listenerExampleAll(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerExampleAll",eventType, rowData);
+        printChange("listenerExampleAll", eventType, rowData);
     }
 
     /**
@@ -92,19 +97,19 @@
      */
     @CanalListener(eventType = {CanalEntry.EventType.UPDATE, CanalEntry.EventType.INSERT, CanalEntry.EventType.DELETE})
     public void listenerAllDml(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
-        printChange("listenerAllDml",eventType, rowData);
+        printChange("listenerAllDml", eventType, rowData);
     }
 
-    public void printChange(String method,CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
+    public void printChange(String method, CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
         if (eventType == CanalEntry.EventType.DELETE) {
             rowData.getBeforeColumnsList().stream().collect(Collectors.toList()).forEach(ele -> {
-                System.out.println("[鏂规硶: "+method+" ,  delete 璇彞 ] --->> 瀛楁鍚�: " + ele.getName() + ", 鍒犻櫎鐨勫�间负: " + ele.getValue());
+                System.out.println("[鏂规硶: " + method + " ,  delete 璇彞 ] --->> 瀛楁鍚�: " + ele.getName() + ", 鍒犻櫎鐨勫�间负: " + ele.getValue());
             });
         }
 
         if (eventType == CanalEntry.EventType.INSERT) {
             rowData.getAfterColumnsList().stream().collect(Collectors.toList()).forEach(ele -> {
-                System.out.println("[鏂规硶: "+method+" ,insert 璇彞 ] --->> 瀛楁鍚�: " + ele.getName() + ", 鏂板鐨勫�间负: " + ele.getValue());
+                System.out.println("[鏂规硶: " + method + " ,insert 璇彞 ] --->> 瀛楁鍚�: " + ele.getName() + ", 鏂板鐨勫�间负: " + ele.getValue());
             });
         }
 
@@ -112,7 +117,7 @@
             for (int i = 0; i < rowData.getAfterColumnsList().size(); i++) {
                 CanalEntry.Column afterColumn = rowData.getAfterColumnsList().get(i);
                 CanalEntry.Column beforeColumn = rowData.getBeforeColumnsList().get(i);
-                System.out.println("[鏂规硶: "+method+" , update 璇彞 ] -->> 瀛楁鍚�," + afterColumn.getName() +
+                System.out.println("[鏂规硶: " + method + " , update 璇彞 ] -->> 瀛楁鍚�," + afterColumn.getName() +
                         " , 鏄惁淇敼: " + afterColumn.getUpdated() +
                         " , 淇敼鍓嶇殑鍊�: " + beforeColumn.getValue() +
                         " , 淇敼鍚庣殑鍊�: " + afterColumn.getValue());

--
Gitblit v1.8.0