|
@@ -28,28 +28,38 @@ public class ItsOpSigPhaseListener_backup implements DisposableBean, Runnable {
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void init() {
|
|
public void init() {
|
|
this.mapper = new ObjectMapper();
|
|
this.mapper = new ObjectMapper();
|
|
|
|
+ restartThread();
|
|
|
|
+ }
|
|
|
|
+ private void restartThread() {
|
|
if (this.thread == null) {
|
|
if (this.thread == null) {
|
|
this.thread = new Thread(this, "Daemon thread for background task");
|
|
this.thread = new Thread(this, "Daemon thread for background task");
|
|
-// this.thread.setDaemon(true);
|
|
|
|
}
|
|
}
|
|
if (!this.thread.isAlive()) {
|
|
if (!this.thread.isAlive()) {
|
|
|
|
+ this.thread.setDaemon(true);
|
|
this.thread.start();
|
|
this.thread.start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
Thread currentThread = Thread.currentThread();
|
|
Thread currentThread = Thread.currentThread();
|
|
- while (currentThread == this.thread && !this.isShutdown) {
|
|
|
|
- long delayMillis = doJob();
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(delayMillis);
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- log.error("{}", e.getMessage());
|
|
|
|
|
|
+ try {
|
|
|
|
+ while (currentThread == this.thread && !this.isShutdown) {
|
|
|
|
+ long delayMillis = doJob();
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(delayMillis);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ log.error("{}", e.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } catch(Throwable t) {
|
|
|
|
+ handleThreadError(t);
|
|
}
|
|
}
|
|
log.info("== ItsOpSigPhaseListener end. ==");
|
|
log.info("== ItsOpSigPhaseListener end. ==");
|
|
}
|
|
}
|
|
|
|
+ private void handleThreadError(Throwable t) {
|
|
|
|
+ restartThread();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private long doJob() {
|
|
private long doJob() {
|
|
long delayMilliSeconds = 3000L;
|
|
long delayMilliSeconds = 3000L;
|
|
@@ -88,4 +98,5 @@ public class ItsOpSigPhaseListener_backup implements DisposableBean, Runnable {
|
|
log.error("{}", e.getMessage());
|
|
log.error("{}", e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|