Hitachi

Hitachi Microservices Platform - Paxos Commit Transaction Orchestrator ユーザーズガイド


6.2.6 TxPropagationRestTemplateInterceptorクラス

説明

Spring FrameworkのRestTemplateによるREST通信時に、トランザクションを伝搬するインタセプタクラスです。APがRestTemplateのインスタンスに登録して使用します。TxPropagationRestTemplateInterceptorの各メソッドは、Spring Frameworkが呼び出します。APが直接TxPropagationRestTemplateInterceptorの各メソッドを使用する必要はありません。APがほかのインタセプタを登録する場合は、特に理由がないかぎりは、TxPropagationRestTemplateInterceptorクラスが最初に呼び出されるように登録してください。

メソッド

TxPropagationRestTemplateInterceptorクラスのメソッドの一覧を次の表に示します。

表6‒5 TxPropagationRestTemplateInterceptorクラスのメソッドの一覧

メソッド

説明

intercept(org.springframework.http.HttpRequest request, byte[] body, org.springframework.http.client.ClientHttpRequestExecution execution)

指定されたリクエストをインタセプトし、レスポンスを返すメソッドです。

パッケージ名称
jp.co.Hitachi.soft.hmppcto.filter.propagation
〈この項の構成〉

(1) intercept(org.springframework.http.HttpRequest request, byte[] body, org.springframework.http.client.ClientHttpRequestExecution execution)

説明

指定されたリクエストをインタセプトし、レスポンスを返します。次の順序で処理を実行します。

  1. HMP-PCTOがトランザクション制御に使用するHTTPヘッダをリクエストに追加してトランザクションを伝搬します。

  2. 引数executionのexcute()メソッドを実行して後続のインタセプタを実行、およびリクエストを送信し、レスポンスを受け取ります。

  3. レスポンスからHMP-PCTOがトランザクション制御に使用するHTTPヘッダを入力してトランザクション制御を実行します。

形式
org.springframework.http.client.ClientHttpResponse intercept(
org.springframework.http.HttpRequest request, byte[] body,
org.springframework.http.client.ClientHttpRequestExecution execution) throws java.io.IOException
引数
org.springframework.http.HttpRequest request:

メソッド、URI、ヘッダを含むリクエストを指定します。

byte[] body:

リクエストの本文を指定します。

org.springframework.http.client.ClientHttpRequestExecution execution:

リクエストの実行に使用するインスタンスを指定します。

戻り値
org.springframework.http.client.ClientHttpResponse:

レスポンスを返します。

例外
java.io.IOException:

I/Oエラーです。リクエストの実行時(引数executionのexcute()メソッド実行時)に送出された例外をそのまま送出します。このメソッドで新たな例外の送出はしません。