// can we still run
if (!isRunAllowed()) {
log.trace("Run not allowed, will reject executing exchange: {}", exchange);
if (exchange.getException() == null) {
exchange.setException(new RejectedExecutionException("Run is not allowed"));
}
callback.done(true);
return true;
}
if (failures.get() >= threshold && System.currentTimeMillis() - lastFailure < halfOpenAfter) {
exchange.setException(new RejectedExecutionException("CircuitBreaker Open: failures: " + failures + ", lastFailure: " + lastFailure));
/*
* If the circuit opens, we have to prevent the execution of any processor.
* The failures count can be set to 0.
*/
failures.set(0);