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 列遞送失敗時的重試行為:

兩個消費者各讀不同欄位:service 只讀 maxAttempts、dispatcher 只讀 backoff。 兩者經同一 RetryPolicyResolver(by type)取得本政策,故同型別的重試上限與退避一致。

Since:
4.0.0
  • Constructor Details

    • RetryPolicy

      public RetryPolicy(int maxAttempts, long baseBackoffSeconds, long maxBackoffSeconds)
      Creates an instance of a RetryPolicy record class.
      Parameters:
      maxAttempts - the value for the maxAttempts record component
      baseBackoffSeconds - the value for the baseBackoffSeconds record component
      maxBackoffSeconds - the value for the maxBackoffSeconds record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxAttempts

      public int maxAttempts()
      Returns the value of the maxAttempts record component.
      Returns:
      the value of the maxAttempts record component
    • baseBackoffSeconds

      public long baseBackoffSeconds()
      Returns the value of the baseBackoffSeconds record component.
      Returns:
      the value of the baseBackoffSeconds record component
    • maxBackoffSeconds

      public long maxBackoffSeconds()
      Returns the value of the maxBackoffSeconds record component.
      Returns:
      the value of the maxBackoffSeconds record component