メインコンテンツまでスキップ

要求・応答区分プログラム

プログラムの用途実装するJavaインターフェース適用する設定画面
ユーザー呼び出しプログラムRequestAndResponseDistinctionBase Setting Management>Institutional Business Information、Base Setting Management>System Business Information

共通部電文の要求/応答を区分する方法は、非常に多様である。

機関の場合、電文種別/業務コードの組み合わせで判断されることもあり、電文の特定フィールドまたは送受信コネクションで区分して処理されることもある。 したがって、要求・応答区分プログラムは各機関とシステムの間別にプログラムを開発して適用する必要がある。

当該プログラムは、必須カスタマイズプログラムである。

開発方法

提供されるインターフェースには、共通部を内部処理電文であるMap方式に変換した後に呼び出すAPIと、受信した電文でそのまま呼び出すAPIがある。

Map方式で変換した後、呼び出すAPI

例えば、はMapで種別コードmsgCbtpCdフィールドの値を照会し、3番目の値が0であれば要求であり、0でなければ応答と判断する。

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, Map<String, Object> header) {
// 1) Field lookup in Map
String msgType = (String) header.get("msgCbtpCd");
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

☑ 入力

  • bxiMessage : 電文処理に必要な情報が保存されている項目
  • header : ヘッダー部をUnmarshalしたMap形式のヘッダー部データ

☑ 出力

  • RequestResponseKindEnum値で要求はREQUEST、応答はRESPONSEを返す

受信した電文データで呼び出すAPI

例えば、対外機関から受信した電文で、種別コード位置の値を照会し、種別コードの3番目の値が0の場合には要求、0でなければ応答と判断する。

ヘッダー部をUnmarshalする前のデータで要求・応答を区分するAPIである。

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, String message) {
// 1) Separate data from field positions in the text
String msgType = message.substring(18, 22);
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

☑ 入力

  • bxiMessage : 当該電文処理に必要な情報が保存されている項目
  • message : 受信した電文データ

☑ 出力

  • RequestResponseKindEnum値で要求はREQUEST、応答はRESPONSEを返す

全体例

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import bxi.api.RequestAndResponseDistinction;
import bxi.common.enums.RequestResponseKindEnum;
import bxi.common.model.ExchangeMessage;

@Component
public class RequestAndResponseDistinctionImpl implements RequestAndResponseDistinction {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, Map<String, Object> header) {
// 1) Field lookup in Map
String msgType = (String) header.get("msgCbtpCd");
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, String message) {
// 1) Separate data from field positions in the text
String msgType = message.substring(18, 22);
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}
}