Spring Retry doesn't works when we use RetryTemplate?

前端 未结 1 1818
一个人的身影
一个人的身影 2020-12-18 15:55

I\'ve Develop a retry mechanism by taking a reference from the following course. Below is the code I developed in Spring Batch, in this code @Recover method is

相关标签:
1条回答
  • 2020-12-18 16:26

    You are using the retryTemplate in a programmatic way, so you need to provide the RecoveryCallback as a second parameter:

      retryTemplate.execute(new MyRetryCallback(), new MyRecoveryCallback());
    

    If you want to use the declarative approach using annotations, you need to annotate the retryable method with @Retryable and the recovery method with @Recover.

    You can find an example of each approach in the home page: https://github.com/spring-projects/spring-retry#quick-start

    0 讨论(0)
提交回复
热议问题