Class ProcessUtils

java.lang.Object
org.axonframework.common.ProcessUtils

public final class ProcessUtils extends Object
Processing utilities.
Since:
4.2
Author:
Marc Gathier
  • Method Details

    • executeWithRetry

      public static void executeWithRetry(Runnable runnable, Predicate<RuntimeException> retryPredicate, long timeout, TimeUnit timeUnit, long retryInterval)
      Executes an action, with potential retry in case of an exception.
      Parameters:
      runnable - action to execute
      retryPredicate - predicate to determine if the action should be retried based on the exception
      timeout - timeout for the retries
      timeUnit - unit for the timeout
      retryInterval - time to wait between retries of the action
    • executeUntilTrue

      public static CompletableFuture<Void> executeUntilTrue(Supplier<CompletableFuture<Boolean>> action, long retryInterval, long maxTries, Executor executor)
      Executes an action asynchronously, with potential retry in case the result is false. Exception handling should be taken care of within the action if needed.
      Parameters:
      action - action to execute, will be executed until the result is true or max tries are reached
      retryInterval - time in milliseconds to wait between retries of the action
      maxTries - maximum number of times the action is invoked
      executor - executor used to schedule the delay between retries
      Returns:
      a CompletableFuture that completes when the action returns true, or exceptionally with a ProcessRetriesExhaustedException if max tries is reached
    • executeUntilTrue

      public static void executeUntilTrue(BooleanSupplier runnable, long retryInterval, long maxTries)
      Executes an action, with potential retry in case the result is false. Exception handling should be taken care of within the action if needed.
      Parameters:
      runnable - action to execute, will be executed till the result is true, or max tries are reached
      retryInterval - time to wait between retries of the action
      maxTries - maximum number of times the action is invoked