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 by execute()

@API(status=INTERNAL) public class Resilience4jRetryWithRecovery<T> extends RetryWithRecovery<T>
This class aims to implement a retry mechanism (on top of aRetry) with different recovery strategies based on predicates.
  • 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 an ApiException, i.e. ApiExceptions will never be ignored.
      Parameters:
      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<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 an ApiException, i.e. ApiExceptions will be ignored if the predicate matches.
      Parameters:
      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<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

      public T execute() throws Throwable
      Method called by client which should implement the retry. This should call RetryWithRecovery.executeOnce() which executes one actual call to the supplier, runs potential recovery actions and potentially throws an exception.
      Specified by:
      execute in class RetryWithRecovery<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.