use of com.adaptris.core.util.ManagedThreadFactory in project interlok by adaptris.
the class AdaptrisMessageWorkerImp method handleConnectionException.
/**
* @see com.adaptris.core.AdaptrisMessageWorker #handleConnectionException()
*/
@Override
public void handleConnectionException() throws CoreException {
if (hasActiveErrorHandler()) {
// spin off exception handler Thread
Thread thread = new ManagedThreadFactory(getClass().getSimpleName()).newThread(new Runnable() {
@Override
public void run() {
retrieveConnection(AdaptrisConnection.class).connectionErrorHandler().handleConnectionException();
}
});
thread.setName("Connection Exc: " + Thread.currentThread().getName());
log.trace("Handling Connection Exception");
thread.start();
}
}
use of com.adaptris.core.util.ManagedThreadFactory in project interlok by adaptris.
the class ActiveJmsConnectionErrorHandler method init.
@Override
public void init() throws CoreException {
super.init();
try {
MyExceptionHandler handler = new MyExceptionHandler();
CountDownLatch verifierThreadGate = new CountDownLatch(1);
verifier = new JmsConnectionVerifier(idForLogging, verifierThreadGate);
Thread verifierThread = new ManagedThreadFactory(getClass().getSimpleName()).newThread(verifier);
verifierThread.setName("JmsConnectionErrorHandler for " + idForLogging);
verifierThread.setUncaughtExceptionHandler(handler);
verifierThread.start();
boolean actuallyStarted = verifierThreadGate.await(DEFAULT_MAX_WAIT_FOR_START.toMilliseconds(), TimeUnit.MILLISECONDS);
if (!actuallyStarted) {
if (handler.hasError()) {
ExceptionHelper.rethrowCoreException(handler.lastException());
} else {
throw new CoreException("Failed to start connection error handler");
}
}
if (additionalLogging()) {
log.debug("ActiveJmsConnectionErrorHandler for {} started", idForLogging);
}
} catch (Exception e) {
ExceptionHelper.rethrowCoreException(e);
}
}
Aggregations