spring @retryable不生效的一種場(chǎng)景分析
項(xiàng)目中某個(gè)位置要調(diào)用其它部門的接口,一直有問(wèn)題,對(duì)方讓加重試。使用@Retryable之后發(fā)現(xiàn)并沒(méi)有進(jìn)行重試,之前其它接口都正常重試了。
經(jīng)過(guò)研究發(fā)現(xiàn)了這個(gè)方法是直接寫(xiě)在調(diào)用的類里面的,這種情況重試竟然不會(huì)進(jìn)行。
在某個(gè)方法中調(diào)用另一個(gè)帶retryable的方法時(shí),如果這個(gè)retry方法在同一個(gè)類中,不會(huì)進(jìn)行重試
執(zhí)行methodA 不會(huì)重試
public class TaskSubSchedule { public void methodA() { System.out.println("開(kāi)始測(cè)試"); methodB(); } @Retryable(value = RuntimeException.class,maxAttempts = 5) public void methodB() { System.out.println("我是方法B"); throw new RuntimeException(); } }
會(huì)重試
public class TaskSubSchedule { @Autowired private CiserviceImpl ciService; public void methodA() { System.out.println("開(kāi)始測(cè)試"); ciService.methodB(); } public class CiServiceImpl { @Retryable(value = RuntimeException.class,maxAttempts = 5) public void methodB() { System.out.println("我是方法B"); throw new RuntimeException(); } } }
到此這篇關(guān)于spring @retryable不生效的一種場(chǎng)景的文章就介紹到這了,更多相關(guān)spring @retryable不生效內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- SpringBoot使用spring retry重試機(jī)制的操作詳解
- Java中使用Spring Retry實(shí)現(xiàn)重試機(jī)制的流程步驟
- 重試框架Guava-Retry和spring-Retry的使用示例
- Spring-Retry(重試機(jī)制)解讀
- SpringBoot中使用spring-retry 解決失敗重試調(diào)用
- Spring-retry實(shí)現(xiàn)循環(huán)重試功能
- spring-retry組件的使用教程
- Spring @Retryable注解輕松搞定循環(huán)重試功能
- Spring?Retry?實(shí)現(xiàn)樂(lè)觀鎖重試實(shí)踐記錄
相關(guān)文章
Spring?boot集成easy?excel實(shí)現(xiàn)導(dǎo)入導(dǎo)出功能
這篇文章主要介紹了Spring?boot集成easy?excel實(shí)現(xiàn)導(dǎo)入導(dǎo)出操作,使用easyexcel,首先要引入easyexcel的maven依賴,具體的版本根據(jù)你的需求去設(shè)置,本文結(jié)合實(shí)例代碼講解的非常詳細(xì),需要的朋友可以參考下2024-05-05spring mvc 和ajax異步交互完整實(shí)例代碼
本篇文章主要介紹了spring mvc 和ajax異步交互完整實(shí)例代碼,簡(jiǎn)單的AJAX+SpringMVC的異步交互小例子,有興趣的可以了解一下。2017-02-02SpringMVC攔截器創(chuàng)建配置及執(zhí)行順序
這篇文章主要為大家介紹了SpringMVC攔截器創(chuàng)建配置及執(zhí)行順序,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05SpringBoot?+?layui?框架實(shí)現(xiàn)一周免登陸功能示例詳解
這篇文章主要介紹了SpringBoot+layui框架實(shí)現(xiàn)一周免登陸功能,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-08-08