我不能用我的财产作为标号来拖延:
@Value("${delayReintentos}")
private long delay;
@Retryable(value = { SQLException.class }, maxAttempts = 3, backoff = @Backoff(delay = delay))
public String simpleRetry() throws SQLException {
counter++;
LOGGER.info("Billing Service Failed "+ counter);
throw new SQLException();
}
Java11,弹簧引导
发布于 2022-03-22 16:25:28
使用delayExpression
代替
/**
* An expression evaluating to the canonical backoff period. Used as an initial value
* in the exponential case, and as a minimum value in the uniform case. Overrides
* {@link #delay()}.
* @return the initial or canonical backoff period in milliseconds.
* @since 1.2
*/
String delayExpression() default "";
参见自述文件:https://github.com/spring-projects/spring-retry#readme
您可以使用SpEL或属性占位符。
@Backoff(delayExpression = "${my.delay}",
maxDelayExpression = "@integerFiveBean", multiplierExpression = "${onePointOne}")
发布于 2022-03-22 16:27:19
通过在大括号中包装属性名来尝试这一点。
@Retryable(value = SQLException.class, maxAttempts = 3, backoff = @Backoff(delayExpression = "${delay}")
https://stackoverflow.com/questions/71575196
复制相似问题