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.


NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License