org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver

## Class CircuitBreakerClientWithRetry

- java.lang.Object
- - org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver.CircuitBreakerClientWithRetry

All Implemented Interfaces:
  Serializable

    @RequestScoped
    public class CircuitBreakerClientWithRetry
    extends Object
    implements Serializable

A client to exercise Circuit Breaker thresholds using Retries.

Author:
  Neil Young, Andrew Rouse
See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`CircuitBreakerClientWithRetry()`

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `getCounterForInvokingServiceA()`
`int` `getCounterForInvokingServiceB()`
`int` `getCounterForInvokingServiceC()`
`Connection` `serviceA()`
`Connection` `serviceB()`
`Connection` `serviceC()` Configured to always time out and Retry until CircuitBreaker is triggered on 4th call.
`String` `serviceWithRetryFailOnCbOpen(boolean throwException)` Has a CircuitBreaker and Retries on all exceptions except TestException and CircuitBreakerOpenException
`String` `serviceWithRetryOnCbOpen(boolean throwException)` Has a CircuitBreaker and Retries on CircuitBreakerOpenException
`String` `serviceWithRetryOnTimeout(boolean throwException)` Has a CircuitBreaker and Retries on TimeoutException

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CircuitBreakerClientWithRetry

    public CircuitBreakerClientWithRetry()

### Method Detail

#### getCounterForInvokingServiceA

    public int getCounterForInvokingServiceA()

#### getCounterForInvokingServiceB

    public int getCounterForInvokingServiceB()

#### getCounterForInvokingServiceC

    public int getCounterForInvokingServiceC()

#### serviceA

    @CircuitBreaker(successThreshold=2,
                    requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=50000L)
     @Retry(retryOn=java.lang.RuntimeException.class,
           maxRetries=7)
    public Connection serviceA()

#### serviceB

    @CircuitBreaker(successThreshold=2,
                    requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=50000L)
     @Retry(retryOn=java.lang.RuntimeException.class,
           maxRetries=2)
    public Connection serviceB()

#### serviceC

    @CircuitBreaker(successThreshold=2,
                    requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=50000L)
     @Retry(retryOn={java.lang.RuntimeException.class,org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException.class},
           maxRetries=7,
           maxDuration=20000L)
     @Timeout(value=100L)
    public Connection serviceC()

Configured to always time out and Retry until CircuitBreaker is triggered on 4th call.

#### serviceWithRetryOnCbOpen

    @CircuitBreaker(requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=1000L)
     @Retry(retryOn=org.eclipse.microprofile.faulttolerance.exceptions.CircuitBreakerOpenException.class,
           maxRetries=20,
           delay=100L,
           jitter=0L)
    public String serviceWithRetryOnCbOpen(boolean throwException)

Has a CircuitBreaker and Retries on CircuitBreakerOpenException

Parameters:
  `throwException` - whether this method should throw a TestException to simulate an application failure
Returns:
  string "OK"

#### serviceWithRetryOnTimeout

    @CircuitBreaker(requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=1000L)
     @Retry(retryOn=org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException.class,
           maxRetries=20,
           delay=200L)
    public String serviceWithRetryOnTimeout(boolean throwException)

Has a CircuitBreaker and Retries on TimeoutException

The method should never throw a TimeoutException so the retry should have no effect

Parameters:
  `throwException` - whether this method should throw a TestException to simulate an application failure
Returns:
  string "OK"

#### serviceWithRetryFailOnCbOpen

    @CircuitBreaker(requestVolumeThreshold=4,
                    failureRatio=0.75,
                    delay=1000L)
     @Retry(abortOn={TestException.class,org.eclipse.microprofile.faulttolerance.exceptions.CircuitBreakerOpenException.class},
           maxRetries=20,
           delay=200L)
    public String serviceWithRetryFailOnCbOpen(boolean throwException)

Has a CircuitBreaker and Retries on all exceptions except TestException and CircuitBreakerOpenException

Parameters:
  `throwException` - whether this method should throw a TestException to simulate an application failure
Returns:
  string "OK"