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:

public class CustomCircuit extends Circuit {

    private AtomicBoolean open = new AtomicBoolean(false);

    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) {;

For more details checkout

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:


Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments