Record Class RetryPolicy
java.lang.Object
java.lang.Record
io.leandev.appfuse.notification.outbox.RetryPolicy
- Record Components:
maxAttempts- 遞送嘗試上限(須 ≥ 1)baseBackoffSeconds- 退避基數秒(須 ≥ 0)maxBackoffSeconds- 退避秒數上限(須 ≥baseBackoffSeconds)
public record RetryPolicy(int maxAttempts, long baseBackoffSeconds, long maxBackoffSeconds)
extends Record
單一通知型別的重試政策
描述某 type 的 Outbox 列遞送失敗時的重試行為:
maxAttempts:嘗試上限,逾此由NotificationOutboxBase.recordFailure(String, Instant)轉DEAD。 由NotificationService在建列時寫入NotificationOutbox.maxAttempts(per-row)。baseBackoffSeconds/maxBackoffSeconds:指數退避參數,由NotificationOutboxDispatcher計算nextAttemptAt(第 n 次失敗後等base × 2ⁿ秒,上限max)。
兩個消費者各讀不同欄位:service 只讀 maxAttempts、dispatcher 只讀 backoff。
兩者經同一 RetryPolicyResolver(by type)取得本政策,故同型別的重試上限與退避一致。
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionRetryPolicy(int maxAttempts, long baseBackoffSeconds, long maxBackoffSeconds) Creates an instance of aRetryPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thebaseBackoffSecondsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxAttemptsrecord component.longReturns the value of themaxBackoffSecondsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RetryPolicy
public RetryPolicy(int maxAttempts, long baseBackoffSeconds, long maxBackoffSeconds) Creates an instance of aRetryPolicyrecord class.- Parameters:
maxAttempts- the value for themaxAttemptsrecord componentbaseBackoffSeconds- the value for thebaseBackoffSecondsrecord componentmaxBackoffSeconds- the value for themaxBackoffSecondsrecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
maxAttempts
public int maxAttempts()Returns the value of themaxAttemptsrecord component.- Returns:
- the value of the
maxAttemptsrecord component
-
baseBackoffSeconds
public long baseBackoffSeconds()Returns the value of thebaseBackoffSecondsrecord component.- Returns:
- the value of the
baseBackoffSecondsrecord component
-
maxBackoffSeconds
public long maxBackoffSeconds()Returns the value of themaxBackoffSecondsrecord component.- Returns:
- the value of the
maxBackoffSecondsrecord component
-