2016-06-16 8 views
0

私はSpring統合で基本的な質問があります。私は他のスレッドで検索しようとしましたが、答えに満足していませんでした。ここに私の質問があります。あらゆるヒントが高く評価されます。

私は4つの異なるソースからデータを並行して取得し、データを集約しようとしています。

スプリットの出力チャネルが直接チャネルの場合は、要求は順次ルーティングされます。

しかし、スプリッタの出力チャネルは受信者リストルータです。私がデバッグしたとき、リクエストは順番にルーティングされていました。そこで、いくつかの分析の結果、ペイロードタイプのルータを並行処理することができることがわかりました。

ルータをペイロードタイプのルータに変更しましたが、依然としてリクエストが順次ルーティングされています。

私は戦略を変更し、Publish-subscriber Channelを使用し、すべての加入チャンネルの出力をアグリゲータに接続して、結果を集約できるようにしました。私はデータを並行して入手することができましたが、応答が集約されているとは思われません。私はそれを間違っているのですか?提案してください!

Spring統合AggregatorとPublish Subscriberの組み合わせ

<int:publish-subscribe-channel id="PublishSubscriberChannel" 
    task-executor="taskExecutor" /> 

<task:executor id="taskExecutor" pool-size="5" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource1" output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource2" output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="getVehicleInfoWithAdditionalAttributes" 
    output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource4" output-channel="lookupAggregatorChannel" /> 

答えて

0

だから、最後に、私は私が間違って何をしていたかが分かりました。 当初、私はSpring Integrationバージョン2.0で作業していました。これは古いアプリケーションです。だから私のコードが質問に与えられたものであったとき、私はAggregatorにルーティングされているリクエストを見ることができませんでした。 その後、Spring Versionを4.3.2 RELEASEにアップグレードしたとき、Correlation Strategyがnullになる可能性があるというエラーが発生しました。つまり、アグリゲータに相関IDが必要であることが判明し、スプリッタ相関IDが自動的に追加され、パブリッシュ/サブスクライブチャネルに対しては、デフォルトの相関IDを追加するためにapply-sequence = "true"を追加する必要があります。アグリゲータによって使用されます。したがって、本質的には、これは私のコードが現在どのように見えていて、まったく問題なく動作しています。

<int:publish-subscribe-channel id="PublishSubscriberChannel" apply-sequence="true" 
    task-executor="taskExecutor" /> 

<task:executor id="taskExecutor" pool-size="5" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource1" output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource2" output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource3" 
    output-channel="lookupAggregatorChannel" /> 

<int:service-activator input-channel="PublishSubscriberChannel" 
    ref="lookUpService" method="lookupSource4" output-channel="lookupAggregatorChannel" />