From 006d66a0578941bcb5f3ab221432b68b741dc310 Mon Sep 17 00:00:00 2001 From: Ngoc Dao Date: Tue, 7 Apr 2015 11:59:59 +0900 Subject: [PATCH] Fix #13 MySQLExtractor: Reconnect after some time on connection failure --- CHANGELOG.md | 5 +++++ src/main/scala/mydit/MySQLExtractor.scala | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 541af65..36ac5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +1.6: + +* [#13](https://github.com/ngocdaothanh/mydit/issues/13) + MySQLExtractor: Reconnect after some time on connection failure + 1.5: * [#12](https://github.com/ngocdaothanh/mydit/issues/12) diff --git a/src/main/scala/mydit/MySQLExtractor.scala b/src/main/scala/mydit/MySQLExtractor.scala index e8493fd..b0210fe 100644 --- a/src/main/scala/mydit/MySQLExtractor.scala +++ b/src/main/scala/mydit/MySQLExtractor.scala @@ -142,7 +142,10 @@ class MySQLExtractor( if (delaySecs > 0) Thread.sleep(delaySecs * 1000) client.connect() } catch { - case NonFatal(e) => Log.error("Error", e) + case NonFatal(e) => + val delay = if (delaySecs > 0) delaySecs else RECONNECT_DELAY_SECS + Log.error(s"Could not connect, will reconnect in $delay seconds", e) + connectInNewThread(delay) } } }.start()