对于同样是@Scheduled 的@Retryable 方法,未发现@Recover 带注释的方法 [英] @Recover annotated method is not discovered for a @Retryable method that also is @Scheduled

查看:30
本文介绍了对于同样是@Scheduled 的@Retryable 方法,未发现@Recover 带注释的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了这个问题的答案 @Recover 方法是没有被@Retryable 触发

I studied the answer from this question @Recover methods are not triggered with @Retryable

但我不明白为什么我的情况下无法运行恢复方法.

But I can't figure out why recover method does not run in my case.

@Service public MyRetryingService {

    @Scheduled(fixedRate = 10 * 1000)
    @Retryable(backoff = @Backoff(delay = 100, maxDelay = 101), maxAttempts = 3)
    public void transferData() {
        throw new IllegalArgumentException();
    }

    @Recover
    public void recover(IllegalArgumentException exception) {
        System.out.println("Recovering from a service down");
    }
}

我收到此异常

org.springframework.retry.ExhaustedRetryException: Cannot locate recovery method; nested exception is java.lang.IllegalArgumentException

我在这里遗漏了什么?

推荐答案

您使用的是哪个版本的 Spring Framework?

What version of Spring Framework are you using?

这是一个最近修复的问题 SPR-16196.

It's a problem that was recently fixed SPR-16196.

这篇关于对于同样是@Scheduled 的@Retryable 方法,未发现@Recover 带注释的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆