java.lang.Object
org.springframework.core.retry.support.RetryTask<V,E>
- Type Parameters:
V- the returned value type, if anyE- the exception propagated, if any
- All Implemented Interfaces:
Callable<V>, TaskCallback<V,E>
public class RetryTask<V extends @Nullable Object, E extends Exception>
extends Object
implements TaskCallback<V,E>
A
TaskCallback that executes a given retryable task,
re-executing it after failure according to a retry policy.
Inherits Callable through TaskCallback.
For regular construction, this is designed to match the
SyncTaskExecutor.execute(TaskCallback)
signature for propagating specific exception types but is
also usable with the Callback-based methods on
AsyncTaskExecutor.
Alternatively, this class can also be used to wrap a
given Callable or Runnable into corresponding
retrying variants: see the common static wrap methods.
This is particularly useful for existing Callable and
Runnable classes, as well as for scheduling methods
which typically accept a Runnable in their signature.
- Since:
- 7.0.4
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRetryTask(TaskCallback<V, E> task) Create a newRetryTaskfor the given retryable task.RetryTask(TaskCallback<V, E> task, RetryOperations retryTemplate) Create a newRetryTaskfor the given retryable task.RetryTask(TaskCallback<V, E> task, RetryPolicy retryPolicy) Create a newRetryTaskfor the given retryable task. -
Method Summary
Modifier and TypeMethodDescriptioncall()getName()Return the name of the retryable task: by default, the class name of the target task.toString()static RunnableWrap the given targetRunnableinto a retryingRunnable.static Runnablewrap(Runnable task, RetryOperations retryTemplate) Wrap the given targetRunnableinto a retryingRunnable.static Runnablewrap(Runnable task, RetryPolicy retryPolicy) Wrap the given targetRunnableinto a retryingRunnable.static <V> Callable<V> Wrap the given targetCallableinto a retryingCallable.static <V> Callable<V> wrap(Callable<V> task, RetryOperations retryTemplate) Wrap the given targetCallableinto a retryingCallable.static <V> Callable<V> wrap(Callable<V> task, RetryPolicy retryPolicy) Wrap the given targetCallableinto a retryingCallable.
-
Constructor Details
-
RetryTask
Create a newRetryTaskfor the given retryable task.- Parameters:
task- a task that allows for re-execution after failure- See Also:
-
RetryTask
Create a newRetryTaskfor the given retryable task.- Parameters:
task- a task that allows for re-execution after failureretryPolicy- the retry policy to apply- See Also:
-
RetryTask
Create a newRetryTaskfor the given retryable task.- Parameters:
task- a task that allows for re-execution after failureretryTemplate- the retry delegate to use (typically aRetryTemplatebut declaring theRetryOperationsinterface for flexibility)
-
-
Method Details
-
call
-
getName
Return the name of the retryable task: by default, the class name of the target task.- See Also:
-
toString
-
wrap
-
wrap
Wrap the given targetCallableinto a retryingCallable.- Parameters:
task- a task that allows for re-execution after failureretryPolicy- the retry policy to apply- See Also:
-
wrap
Wrap the given targetCallableinto a retryingCallable.- Parameters:
task- a task that allows for re-execution after failureretryTemplate- the retry delegate to use (typically aRetryTemplatebut declaring theRetryOperationsinterface for flexibility)
-
wrap
-
wrap
Wrap the given targetRunnableinto a retryingRunnable.- Parameters:
task- a task that allows for re-execution after failureretryPolicy- the retry policy to apply- See Also:
-
wrap
Wrap the given targetRunnableinto a retryingRunnable.- Parameters:
task- a task that allows for re-execution after failureretryTemplate- the retry delegate to use (typically aRetryTemplatebut declaring theRetryOperationsinterface for flexibility)
-