T
- the type of the object returned by execute()
@API(status=INTERNAL) public class Resilience4jRetryWithRecovery<T> extends RetryWithRecovery<T>
Retry
)
with different recovery strategies based on predicates.Constructor and Description |
---|
Resilience4jRetryWithRecovery(java.lang.String name,
java.lang.String address,
BdkRetryConfig bdkRetryConfig,
SupplierWithApiException<T> supplier,
java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate,
java.util.List<RecoveryStrategy> recoveryStrategies)
Constructor with no predicate on when to ignore an
ApiException ,
i.e. |
Resilience4jRetryWithRecovery(java.lang.String name,
java.lang.String address,
BdkRetryConfig bdkRetryConfig,
SupplierWithApiException<T> supplier,
java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate,
java.util.function.Predicate<java.lang.Exception> ignoreException,
java.util.List<RecoveryStrategy> recoveryStrategies)
Constructor with a predicate on when to ignore an
ApiException ,
i.e. |
Modifier and Type | Method and Description |
---|---|
T |
execute()
Method called by client which should implement the retry.
|
executeAndRetry, executeOnce, networkIssueMessageError
public Resilience4jRetryWithRecovery(java.lang.String name, java.lang.String address, BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate, java.util.List<RecoveryStrategy> recoveryStrategies)
ApiException
,
i.e. ApiExceptions will never be ignored.name
- the name of the Retry
service.bdkRetryConfig
- the retry configuration to be used.supplier
- the supplier responsible to provide the object of param type T and which may throw an ApiException
.retryOnExceptionPredicate
- predicate on a thrown ApiException
to know if call should be retried.recoveryStrategies
- mapping between Predicate
and the corresponding recovery functions to be executed before retrying.
If several predicates match, all corresponding consumers will be executed.public Resilience4jRetryWithRecovery(java.lang.String name, java.lang.String address, BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, java.util.function.Predicate<java.lang.Throwable> retryOnExceptionPredicate, java.util.function.Predicate<java.lang.Exception> ignoreException, java.util.List<RecoveryStrategy> recoveryStrategies)
ApiException
,
i.e. ApiExceptions will be ignored if the predicate matches.name
- the name of the Retry
service.bdkRetryConfig
- the retry configuration to be used.supplier
- the supplier responsible to provide the object of param type T and which may throw an ApiException
.retryOnExceptionPredicate
- predicate on a thrown ApiException
to know if call should be retried.ignoreException
- predicate on a thrown Exception
to know if exception should be ignored,
which means no subsequent retry will be made and null value will be returned.recoveryStrategies
- mapping between Predicate
and the corresponding recovery functions to be executed before retrying.
If several predicates match, all corresponding consumers will be executed.public T execute() throws java.lang.Throwable
RetryWithRecovery.executeOnce()
which executes one actual call to the supplier, runs potential recovery
actions and potentially throws an exception.execute
in class RetryWithRecovery<T>
java.lang.Throwable
- in case the max number of retries exhausted
or if any other exception thrown by the supplier or the recovery functions.