【问题标题】:How to use exceptionExpression in Spring Retryable?如何在 Spring Retryable 中使用 exceptionExpression?
【发布时间】:2022-12-19 23:54:13
【问题描述】:

所以我有一个基本方法,它已经有 @Retryable 注释。我最近遇到了“exceptionExpression”来抑制基于某些条件的重试。我想知道有哪些方法可以使用此 exceptionExpression。我试过 message.contains 方法。但是我可以使用布尔函数的结果来做同样的事情吗?

【问题讨论】:

    标签: java spring spring-boot spring-retry


    【解决方案1】:

    请参阅 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
     */
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-30
      • 2017-12-03
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 2018-06-30
      • 2018-08-08
      相关资源
      最近更新 更多