【发布时间】:2022-12-19 23:54:13
【问题描述】:
所以我有一个基本方法,它已经有 @Retryable 注释。我最近遇到了“exceptionExpression”来抑制基于某些条件的重试。我想知道有哪些方法可以使用此 exceptionExpression。我试过 message.contains 方法。但是我可以使用布尔函数的结果来做同样的事情吗?
【问题讨论】:
标签: java spring spring-boot spring-retry
所以我有一个基本方法,它已经有 @Retryable 注释。我最近遇到了“exceptionExpression”来抑制基于某些条件的重试。我想知道有哪些方法可以使用此 exceptionExpression。我试过 message.contains 方法。但是我可以使用布尔函数的结果来做同样的事情吗?
【问题讨论】:
标签: java spring spring-boot spring-retry
请参阅 Java 文档:
/**
* Specify an expression to be evaluated after the
* {@code SimpleRetryPolicy.canRetry()} returns true - can be used to conditionally
* suppress the retry. Only invoked after an exception is thrown. The root object for
* the evaluation is the last {@code Throwable}. Other beans in the context can be
* referenced. For example: <pre class=code>
* {@code "message.contains('you can retry this')"}.
* </pre> and <pre class=code>
* {@code "@someBean.shouldRetry(#root)"}.
* </pre>
* @return the expression.
* @since 1.2
*/
【讨论】: