Class Resilience4jRetryWithRecovery<T>
java.lang.Object
com.symphony.bdk.core.retry.RetryWithRecovery<T>
com.symphony.bdk.core.retry.resilience4j.Resilience4jRetryWithRecovery<T>
- Type Parameters:
T
- the type of the object returned byexecute()
This class aims to implement a retry mechanism (on top of a
Retry
)
with different recovery strategies based on predicates.-
Constructor Summary
ConstructorDescriptionResilience4jRetryWithRecovery
(String name, String address, com.symphony.bdk.core.config.model.BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, Predicate<Throwable> retryOnExceptionPredicate, Predicate<Exception> ignoreException, List<RecoveryStrategy> recoveryStrategies) Constructor with a predicate on when to ignore anApiException
, i.e.Resilience4jRetryWithRecovery
(String name, String address, com.symphony.bdk.core.config.model.BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, Predicate<Throwable> retryOnExceptionPredicate, List<RecoveryStrategy> recoveryStrategies) Constructor with no predicate on when to ignore anApiException
, i.e. -
Method Summary
Methods inherited from class com.symphony.bdk.core.retry.RetryWithRecovery
executeAndRetry, executeOnce, networkIssueMessageError
-
Constructor Details
-
Resilience4jRetryWithRecovery
public Resilience4jRetryWithRecovery(String name, String address, com.symphony.bdk.core.config.model.BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, Predicate<Throwable> retryOnExceptionPredicate, List<RecoveryStrategy> recoveryStrategies) Constructor with no predicate on when to ignore anApiException
, i.e. ApiExceptions will never be ignored.- Parameters:
name
- the name of theRetry
service.bdkRetryConfig
- the retry configuration to be used.supplier
- the supplier responsible to provide the object of param type T and which may throw anApiException
.retryOnExceptionPredicate
- predicate on a thrownApiException
to know if call should be retried.recoveryStrategies
- mapping betweenPredicate<com.symphony.bdk.http.api.ApiException>
and the corresponding recovery functions to be executed before retrying. If several predicates match, all corresponding consumers will be executed.
-
Resilience4jRetryWithRecovery
public Resilience4jRetryWithRecovery(String name, String address, com.symphony.bdk.core.config.model.BdkRetryConfig bdkRetryConfig, SupplierWithApiException<T> supplier, Predicate<Throwable> retryOnExceptionPredicate, Predicate<Exception> ignoreException, List<RecoveryStrategy> recoveryStrategies) Constructor with a predicate on when to ignore anApiException
, i.e. ApiExceptions will be ignored if the predicate matches.- Parameters:
name
- the name of theRetry
service.bdkRetryConfig
- the retry configuration to be used.supplier
- the supplier responsible to provide the object of param type T and which may throw anApiException
.retryOnExceptionPredicate
- predicate on a thrownApiException
to know if call should be retried.ignoreException
- predicate on a thrownException
to know if exception should be ignored, which means no subsequent retry will be made and null value will be returned.recoveryStrategies
- mapping betweenPredicate<com.symphony.bdk.http.api.ApiException>
and the corresponding recovery functions to be executed before retrying. If several predicates match, all corresponding consumers will be executed.
-
-
Method Details
-
execute
Method called by client which should implement the retry. This should callRetryWithRecovery.executeOnce()
which executes one actual call to the supplier, runs potential recovery actions and potentially throws an exception.- Specified by:
execute
in classRetryWithRecovery<T>
- Returns:
- the object returned by the supplier.
- Throws:
Throwable
- in case the max number of retries exhausted or if any other exception thrown by the supplier or the recovery functions.
-