Package org.axonframework.common
Class ProcessUtils
java.lang.Object
org.axonframework.common.ProcessUtils
Processing utilities.
- Since:
- 4.2
- Author:
- Marc Gathier
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteUntilTrue(BooleanSupplier runnable, long retryInterval, long maxTries) Executes an action, with potential retry in case the result is false.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.static voidexecuteWithRetry(Runnable runnable, Predicate<RuntimeException> retryPredicate, long timeout, TimeUnit timeUnit, long retryInterval) Executes an action, with potential retry in case of an exception.
-
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 executeretryPredicate- predicate to determine if the action should be retried based on the exceptiontimeout- timeout for the retriestimeUnit- unit for the timeoutretryInterval- 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 istrueor max tries are reachedretryInterval- time in milliseconds to wait between retries of the actionmaxTries- maximum number of times the action is invokedexecutor- executor used to schedule the delay between retries- Returns:
- a
CompletableFuturethat completes when the action returnstrue, or exceptionally with aProcessRetriesExhaustedExceptionif max tries is reached
-
executeUntilTrue
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 reachedretryInterval- time to wait between retries of the actionmaxTries- maximum number of times the action is invoked
-