diff --git a/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java b/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java index 195fdae2..f8a6b84a 100644 --- a/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java +++ b/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java @@ -102,8 +102,8 @@ protected enum WorkerState private static final Logger log = LoggerFactory.getLogger(WorkerImpl.class); private static final AtomicLong workerCounter = new AtomicLong(0); protected static final long emptyQueueSleepTime = 500; // 500 ms - private static final long reconnectSleepTime = 5000; // 5s - private static final int reconnectAttempts = 120; // Total time: 10min + protected static final long reconnectSleepTime = 5000; // 5s + protected static final int reconnectAttempts = 120; // Total time: 10min private static volatile boolean threadNameChangingEnabled = false; // set the thread name to the message for debugging /** @@ -162,7 +162,7 @@ protected static void checkQueues(final Iterable queues) "Worker-" + this.workerId + " Jesque-" + VersionUtils.getVersion() + ": "; private final AtomicReference workerThreadRef = new AtomicReference(null); - private final AtomicReference exceptionHandlerRef = + protected final AtomicReference exceptionHandlerRef = new AtomicReference(new DefaultWorkerExceptionHandler()); /** @@ -535,8 +535,16 @@ protected void recoverFromException(final String curQueue, final Exception e) this.jedis.disconnect(); try { Thread.sleep(reconnectSleepTime); } catch (Exception e2){} this.jedis.connect(); + String pingResult = this.jedis.ping(); + if( !pingResult.equals("PONG") ) { + log.info("Unknown redis ping result: " + pingResult); + this.jedis.disconnect(); + } } catch (JedisConnectionException jce){} // Ignore bad connection attempts + catch (Exception e3) { + log.error("Unknown Exception while trying to reconnect to jedis", e3); + } } while (++i <= reconAttempts && !this.jedis.isConnected()); if (!this.jedis.isConnected()) {