2017-06-27 6 views
1

私は以下のケーススタディに取り組んでいます。Spring IntegrationでQueueChannelを使用する

  1. 参照IDを受け入れるレストサービスを作成します。
  2. 「参照ID」を使用して、データベースからデータ(CLOB)を取得します。
  3. さらに処理するために、データ(CLOB)をチャネル(キュー)に入れます。
  4. JSON形式{「ステータス」:真、「メッセージ」:「受信」}で応答データと残りのクライアントに返信

私は休憩サービスが作成されており、文献IDを使用してデータを取得していますデータベースから、私はチャネル(キュー)にメッセージを入れた後、残りのクライアントに応答を返すことができません。残りのクライアントが受信した 出力は、次のとおりです。返事は基本的に私は、チャネル(キュー)にプッシュされたリクエスト・スレッドがデータ(CLOB)の直後に返すことにしたいタイムアウト

内に受信されません。

以下はその構成です。

<int:channel id="responseChannel"/> 
<int:channel id="initCalculation"> 
    <int:queue/> 
</int:channel> 


<!-- GET --> 
<int-http:inbound-gateway 
    request-channel="httpGetChannel" 
    reply-channel="responseChannel" 
    supported-methods="GET" 
    path="/init/{refId}" 
    payload-expression="#pathVariables.refId"> 

    <int-http:request-mapping produces="application/json"/> 

</int-http:inbound-gateway> 


<int:chain input-channel="httpGetChannel" output-channel="initCalculation"> 
    <int-jdbc:stored-proc-outbound-gateway 
      id="outbound-gateway-storedproc-get-forma" data-source="dataSource" 
      is-function="false" 
      stored-procedure-name="XX_EMPROC.GET_FRMA" 
      ignore-column-meta-data="true" 
      expect-single-result="true"> 

     <int-jdbc:sql-parameter-definition name="V_REF_ID" direction="IN" /> 
     <int-jdbc:sql-parameter-definition name="V_FRMA" direction="OUT" type="#{T(oracle.jdbc.OracleTypes).CLOB}"/> 

     <int-jdbc:parameter name="V_REF_ID" expression="payload" /> 
    </int-jdbc:stored-proc-outbound-gateway> 

    <!- Convert to JSON Format --> 
    <int:service-activator ref="brInitGateway" method="getResponse"/> 

</int:chain> 


<int:outbound-channel-adapter channel="initCalculation" ref="brInitGateway" method="process"/> 

上記の修正が必要です。

おかげ

答えて

1

見て、<int-http:inbound-gateway>への応答としてメッセージを送信全く体はありません。あなたはresponseChannelと宣言しましたが、誰がそれをoutput-channelとして使用しようとしていますか?

私はあなたがこれを行うにお勧めしたい:

<publish-subscribe-channel id="responseChannel"/> 

<int:chain input-channel="httpGetChannel" output-channel="responseChannel"> 


<int:bridge input-channel="responseChannel" output-channel="initCalculation"/> 

だから、ここで何が起こる:reply-channelため

publish-subscribe-channelは、加入者の一つとしてreplyChannelヘッダへの内部ブリッジになります。

<chain>の結果をそのチャンネルに送信します。したがって、<int-http:inbound-gateway>は返信を取得します。

<int:bridge>initCalculationへの応答から取得すると、2番目のサブスクライバがあるため、必要なキューにメッセージを送信します。

あなたがHTTP要求に対する応答としてbrInitGateway.getResponse()に興味を持っていない場合は、あなたがすべてでreply-channel="responseChannel"が、それでも返信を準備するためにキューといくつかの変圧器に送信するためにいくつかの<publish-subscribe-channel>を使用することはありません考慮すべきである、例えば:従って<int-http:inbound-gateway>イニシエータに、replyChannelヘッダにその結果を送信しようとしているので

<transformer input-channel="prepareProcess" expression="' {"status": true,"message": "RECEIVED"}'"/> 

この変圧器は、output-channelなしです。

+0

応答を送信しない場合は、ゲートウェイの代わりにインバウンドチャネルアダプタを使用することもできます。 CLOBをキュー・チャネルに渡すと、デフォルトで200OKが送信されます。 –

+0

@GaryRussell - 提案をありがとう。それを覚えておいてください。 –

+0

@Artem Bilan - あなたのソリューションに感謝します。私のユースケースでは完璧に機能しました。 –

関連する問題