Configurable CircuitBreaker For Java EE 📎
breakr is a simplistic interceptor (6KB) which ignores all calls to the decorated component when a configurable threshold is reached.
The decision when to open or close the circuit and the information about the state of the breakr is maintained in the class com.airhacks.breakr.Circuit
.
To introduce custom behavior, just inherit from the Circuit and introduce your own business logic:
@ApplicationScoped
@Specializes
public class CustomCircuit extends Circuit {
private AtomicBoolean open = new AtomicBoolean(false);
@Override
public boolean isOpen(long maxFailures) {
return open.get();
}
public long getFailureCount() {
return failureCounter.get();
}
/**
* controls the closing and opening of the circuit
*/
public void setOpen(boolean open) {
this.open.set(open);
}
}
For more details checkout github.com/AdamBien/breakr.
See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.