Class RetryUtil
java.lang.Object
cn.toint.oktool.util.RetryUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> R重试机制static <R> Rexecute(Callable<R> callable, int retrySize, Duration intervalTime, boolean printStackTrace, Class<? extends Throwable>... exceptionClass) 重试机制static <R> Rexecute(Callable<R> callable, int retrySize, Duration intervalTime, Class<? extends Throwable>... exceptionClass) 重试机制static <R> R重试机制static <R> Rexecute(Callable<R> callable, Collection<RetryPolicy> retryPolicies) 重试机制
-
Constructor Details
-
RetryUtil
public RetryUtil()
-
-
Method Details
-
execute
重试机制- Type Parameters:
R- 返回类型- Parameters:
callable- 执行方法- Returns:
- 方法执行结果
- Throws:
RetryException- 重试失败
-
execute
@SafeVarargs public static <R> R execute(Callable<R> callable, Class<? extends Throwable>... exceptionClass) 重试机制- Type Parameters:
R- 返回类型- Parameters:
callable- 执行方法exceptionClass- 需要重试的异常类型 (默认RuntimeException)- Returns:
- 方法执行结果
- Throws:
RetryException- 重试失败
-
execute
@SafeVarargs public static <R> R execute(Callable<R> callable, int retrySize, Duration intervalTime, Class<? extends Throwable>... exceptionClass) 重试机制- Type Parameters:
R- 返回类型- Parameters:
callable- 执行方法retrySize- 重试次数 (不包含首次执行, 小于1表示不重试, 但无论如何方法会执行1次)intervalTime- 间隔时间 (null 或 小于等于0, 表示立刻重试不会等待)exceptionClass- 需要重试的异常类型 (默认RuntimeException)- Returns:
- 方法执行结果
- Throws:
RetryException- 重试失败
-
execute
@SafeVarargs public static <R> R execute(Callable<R> callable, int retrySize, Duration intervalTime, boolean printStackTrace, Class<? extends Throwable>... exceptionClass) 重试机制- Type Parameters:
R- 返回类型- Parameters:
callable- 执行方法retrySize- 重试次数 (不包含首次执行, 小于1表示不重试, 但无论如何方法会执行1次)intervalTime- 间隔时间 (null 或 小于等于0, 表示立刻重试不会等待)printStackTrace- 重试时是否打印异常信息 (false 不打印)exceptionClass- 需要重试的异常类型 (默认RuntimeException)- Returns:
- 方法执行结果
- Throws:
RetryException- 重试失败
-
execute
重试机制- Type Parameters:
R- 返回类型- Parameters:
callable- 执行方法retryPolicies- 重试策略- Returns:
- 方法执行结果
- Throws:
RetryException- 重试失败
-