From ed3a1614384279b7d3a97e7411b649476a934ddb Mon Sep 17 00:00:00 2001 From: duxinglangzi <871364441@qq.com> Date: 星期二, 06 九月 2022 15:14:48 +0800 Subject: [PATCH] add LICENSE. --- src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java b/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java index 95007e7..c0a5094 100644 --- a/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java +++ b/src/main/java/com/duxinglangzi/canal/starter/container/AbstractCanalTransponderContainer.java @@ -9,8 +9,9 @@ import java.util.concurrent.TimeUnit; /** + * 鎶借薄鐨刢anal transponder ,瀹炵幇SmartLifecycle鎺ュ彛,澹版槑鍛ㄦ湡鐢眘pring杩涜绠$悊 + * * @author wuqiong 2022/4/11 - * @description */ public abstract class AbstractCanalTransponderContainer implements SmartLifecycle { protected boolean isRunning = false; @@ -21,18 +22,23 @@ CanalEntry.EntryType.HEARTBEAT); protected abstract void doStart(); + protected abstract void initConnect(); + + protected abstract void disconnect(); @Override public void start() { - setRunning(true); new Thread(() -> { + // spring 鍚姩鍚� 鎵嶄細杩涜canal鏁版嵁鎷夊彇 while (!ApplicationReadyListener.START_LISTENER_CONTAINER.get()) sleep(5L * SLEEP_TIME_MILLI_SECONDS); initConnect(); while (isRunning() && !Thread.currentThread().isInterrupted()) doStart(); + disconnect(); // 绾跨▼琚粓姝㈡垨鑰呭鍣ㄥ凡缁忓仠姝�,闇�瑕佸叧闂繛鎺� }).start(); + setRunning(true); } @Override @@ -44,6 +50,7 @@ public void stop(Runnable callback) { callback.run(); setRunning(false); + sleep(SLEEP_TIME_MILLI_SECONDS); } @Override @@ -51,7 +58,7 @@ return isRunning; } - protected void setRunning(boolean bool){ + protected void setRunning(boolean bool) { isRunning = bool; } -- Gitblit v1.8.0