Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 61 java ee the handler will be executed and 42 will be returned as the amount Listing 8 @ Timeout 3000 @ Fallback MyFallback class Long getAmount return service retrieveAmount public class MyFallback implements FallbackHandler Long Long handle ExecutionContext context return 42 CircuitBreaker This feature prevents repeating failure scenarios so that invocation of a microservice fails as fast as possible Listing 9 shows an example of a CircuitBreaker definition on a method call CircuitBreaker can be used with Timeout Fallback Asynchronous Bulkhead and RetryPolicy Listing 9 @ CircuitBreaker successThreshold 10 requestVolumeThreshold 4 failureRatio 075 delay 1000 public void invokeService invoke an external service This CircuitBreaker specifies that the circuit will open meaning that calls to the invokeService method will fail once three failures requestVolumeThreshold x failureRatio occur within the
You must have JavaScript enabled to view digital editions.