spring 重試機制,設定最大延遲時間

2021-10-21 14:33:17 字數 388 閱讀 3717

在使用spring重試機制時遇到幾個問題,乙個是重試機制不執行,乙個原因可能是因為重試方法不能在本類中呼叫,在本類中呼叫會導致**失效,

還有乙個原因可能是因為異常沒有在方法外通過throws丟擲來。

還有乙個問題是設定延遲重試時間delay和延遲倍數multiplier,但是沒有設定maxdelay最大延遲時間,則會使用預設最大延遲時間30秒

導致前面設定的延遲時間和延遲倍數如果超過30秒就會失效,最大只延遲30秒

@retryable(value = swlhycodeexception.class, maxattempts = 3,

backoff = @backoff(delay = 300000l, multiplier = 2, maxdelay = 1200000l))

Spring重試機制

org.springframework.retrygroupid spring retryartifactid dependency org.springframework.bootgroupid spring boot starter aopartifactid dependency 程式啟動類新...

中斷重試機制

原文 中斷重試 中斷重試機制 public abstract class retrytemplate public retrytemplate setsleeptime int sleeptime this sleeptime sleeptime return this public intgetr...

Polly 重試機制

引用 install package microsoft.extensions.http.polly 在core中的使用 方式一 先配置再執行 注意 執行 executeasync 方法,異常會丟擲 方式二 邊配置邊執行 result await policy handle ex ex.code 4...