Record Class DeliveryResult

java.lang.Object
java.lang.Record
io.leandev.appfuse.notification.DeliveryResult
Record Components:
delivered - 是否遞送成功
suppressed - 是否因政策被抑制(確定性、不重試);僅在 delivered=false 時有意義
detail - 補充訊息(成功可為 provider 回執;失敗 / 抑制為原因)

public record DeliveryResult(boolean delivered, boolean suppressed, String detail) extends Record

單則通道遞送的結果

NotificationChannel.send(OutboundMessage) 的回傳。delivered 為 false 時 detail 應載明原因, 供 Outbox 記錄 lastError 並決定後續處理。

三種結果:

  • 成功delivered=true)→ Outbox 轉 SENT
  • 失敗delivered=false, suppressed=false)→ 可重試,Outbox 退避重試、逾上限轉 DEAD
  • 抑制delivered=false, suppressed=true)→ 確定性政策封鎖(如防火牆全擋),不重試, Outbox 直接轉 SUPPRESSED。與失敗區分,避免無謂重試與假成功
Since:
4.0.0
  • Constructor Details

    • DeliveryResult

      public DeliveryResult(boolean delivered, boolean suppressed, String detail)
      Creates an instance of a DeliveryResult record class.
      Parameters:
      delivered - the value for the delivered record component
      suppressed - the value for the suppressed record component
      detail - the value for the detail record component
  • Method Details

    • ok

      public static DeliveryResult ok()
      遞送成功
      Returns:
      成功結果
    • failed

      public static DeliveryResult failed(String detail)
      遞送失敗(可重試)
      Parameters:
      detail - 失敗原因
      Returns:
      失敗結果
    • suppressed

      public static DeliveryResult suppressed(String detail)
      因政策被抑制(確定性封鎖,不重試)
      Parameters:
      detail - 抑制原因
      Returns:
      抑制結果
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • delivered

      public boolean delivered()
      Returns the value of the delivered record component.
      Returns:
      the value of the delivered record component
    • suppressed

      public boolean suppressed()
      Returns the value of the suppressed record component.
      Returns:
      the value of the suppressed record component
    • detail

      public String detail()
      Returns the value of the detail record component.
      Returns:
      the value of the detail record component