public class PushNotificationService
extends org.iplass.mtp.impl.pushnotification.PushNotificationService
FCM V1 API を利用した Push 通知を実現する機能です。 FCM については、FCM サービス概要 を確認すること。
Push通知を行う際の PushNotification は次のように設定されることを想定している。
org.iplass.mtp.pushnotification.PushNotification#setMessage(Map) に メッセージリソースの仕様 の通りに情報を設定する。宛先を含める。org.iplass.mtp.pushnotification.PushNotification#setMessage(Map) に メッセージリソースの仕様 の通りに情報が設定する。org.iplass.mtp.pushnotification.PushNotification#addTo(String) で必要な宛先情報を追加する。PushNotificationTargetType.getPrefixedValue(String) を利用して付与する。
org.iplass.mtp.pushnotification.PushNotification#setMessage(Map) を利用しない場合、その他のメソッドに通知に関する情報を設定する。org.iplass.mtp.pushnotification.PushNotification#addTo(String) で必要な宛先情報を追加する。PushNotificationTargetType.getPrefixedValue(String) を利用して付与する。
| コンストラクタと説明 |
|---|
PushNotificationService() |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
void |
destroy() |
protected PushNotificationResponseDetail |
handleResponse(PushNotificationTarget target,
int code,
java.lang.String response,
long retryAfterSeconds)
実行結果をハンドリングする
外部サービスの実行結果を受け、通知の結果を生成する。
|
void |
init(Config config) |
protected void |
postProcessOfReequestPushApi(PushNotificationResponseDetail responseDetail)
通知APIリクエスト後処理
API の結果によって実行する処理を定義する。
|
protected PushNotificationResult |
pushImpl(Tenant tenant,
PushNotification notification) |
protected PushNotificationResponseDetail |
requestPushApi(PushNotificationTarget target,
java.util.Map<java.lang.String,java.lang.Object> messageResource)
FCM V1 API リクエストを行う
FCM 送信 API仕様 に沿ったリクエストを行う。
|
protected PushNotificationResponseDetail |
requestPushApiExponentialBackoff(PushNotificationTarget target,
java.util.Map<java.lang.String,java.lang.Object> messageResource)
指数バックオフリトライを考慮した、FCM V1 API リクエストを行う
リトライ可能なエラーの場合は、レスポンスヘッダ "retry-after" の秒数待ち再度リクエストを行う。
|
public void init(Config config)
public void destroy()
protected PushNotificationResult pushImpl(Tenant tenant,
PushNotification notification)
protected PushNotificationResponseDetail requestPushApiExponentialBackoff(PushNotificationTarget target, java.util.Map<java.lang.String,java.lang.Object> messageResource)
リトライ可能なエラーの場合は、レスポンスヘッダ "retry-after" の秒数待ち再度リクエストを行う。 それ以外の場合は、リトライせず処理を終了する。
target - 宛先情報messageResource - メッセージリソース Map インスタンスprotected PushNotificationResponseDetail requestPushApi(PushNotificationTarget target, java.util.Map<java.lang.String,java.lang.Object> messageResource)
FCM 送信 API仕様 に沿ったリクエストを行う。
実行結果は handleResponse(PushNotificationTarget, int, String, long) でハンドリングする
target - 宛先情報messageResource - メッセージリソース Map インスタンスprotected PushNotificationResponseDetail handleResponse(PushNotificationTarget target, int code, java.lang.String response, long retryAfterSeconds) throws java.io.IOException
外部サービスの実行結果を受け、通知の結果を生成する。
target - 通知対象code - API 実行結果(HttpStatus)response - レスポンスボディretryAfterSeconds - 再実行間隔(秒)java.io.IOException - 入出力例外protected void postProcessOfReequestPushApi(PushNotificationResponseDetail responseDetail)
API の結果によって実行する処理を定義する。
responseDetail -