Class InAppNotificationChannel<T extends InAppNotificationBase>
java.lang.Object
io.leandev.appfuse.notification.channel.InAppNotificationChannel<T>
- Type Parameters:
T- 應用宣告的具體站內信 entity(繼承InAppNotificationBase)
- All Implemented Interfaces:
NotificationChannel
public class InAppNotificationChannel<T extends InAppNotificationBase>
extends Object
implements NotificationChannel
IN_APP 通道(Phase 3):遞送即寫一列站內信
不經外部 provider——「遞送」就是把通知存進 DB,使用者經 app REST API 讀取。位址=userId
(由 Recipient.addressFor(ChannelType) 對 IN_APP 回傳)。
依 ADR-017:具體站內信
entity 由應用宣告,故本通道泛型化於 InAppNotificationBase,並以 entityFactory(應用注入的
T::new)建立實體。不設租戶——tenant 專案的 entity 帶 @TenantId,遞送在 dispatcher 的
TenantContext.runAs(String, Runnable) 內執行,Hibernate 於 persist 時自動填入
當前租戶(決策三);ownership 專案的 entity 無租戶欄位。jar 全程不觸碰租戶欄位。
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionInAppNotificationChannel(InAppNotificationRepositoryBase<T> repository, Supplier<T> entityFactory) -
Method Summary
-
Constructor Details
-
InAppNotificationChannel
public InAppNotificationChannel(InAppNotificationRepositoryBase<T> repository, Supplier<T> entityFactory) - Parameters:
repository- 站內信 repository(應用宣告的具體型別)entityFactory- 建立站內信 entity 的工廠(應用注入,通常為AppInAppNotification::new)
-
-
Method Details
-
type
Description copied from interface:NotificationChannel本通道處理的通道型別- Specified by:
typein interfaceNotificationChannel- Returns:
- 通道型別
-
send
Description copied from interface:NotificationChannel遞送一則訊息
實作不應拋例外表達遞送失敗,改回傳
DeliveryResult.failed(String);拋出的 runtime 例外 由NotificationOutboxDispatcher視同失敗並記錄。- Specified by:
sendin interfaceNotificationChannel- Parameters:
message- 要遞送的訊息- Returns:
- 遞送結果
-