O'Reilly logo

Hands-On Enterprise Java Microservices with Eclipse MicroProfile by Scott Stark, Antoine Sabot-Durand, Pavol Loffay, Jeff Mesnil, Heiko W. Rupp, Cesar Saavedra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The @CircuitBreaker policy

The @CircuitBreaker annotation can be applied to a class or method. The circuit breaker pattern was introduced by Martin Fowler to protect the execution of an operation by making it fail fast in case of a dysfunction:

@CircuitBreaker(requestVolumeThreshold = 4, failureRatio=0.75, delay = 1000)public void operationCouldBeShortCircuited(){  ...}

In the previous example, the method applies the CircuitBreaker policy. The circuit will be opened if three (4 x 0.75) failures occur among the rolling window of four consecutive invocations. The circuit will stay open for 1,000 ms and then be back to half-open. After a successful invocation, the circuit will be back to closed again.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required