2012-12-03 7 views
5

私は春の統合に慣れていません。私は以下のように私の設定ファイルで設定されたいくつかのチャンネルがあります。Spring統合メッセージハンドラチェーンの使用法?

<int:channel id="channelOne" /> 
<int:channel id="channelTwo" /> 
<int:channel id="channelThree" /> 

私はこのシナリオでMessageHandlerChain(http://static.springsource.org/spring-integration/docs/2.0.0.RC1/reference/html/chain.html)を使用することができますか?

ありがとうございます!

+1

の有用性を理解していることを願って、あなたは2 channを持っています定義されたels、入力と出力チャネル。 – tjg184

+0

@ tjg184、私は1つの入力チャンネルと出力チャンネルを持っていますが、何らかのバリデーションを行う入力チャンネルと出力チャンネルの間にもう1つのチャンネル(channelTwo)があります。このシナリオでメッセージハンドラチェーンを使用できますか? – user1016403

答えて

3

私はチャネルインターセプタ(http://static.springsource.org/spring-integration/docs/latest-ga/reference/htmlsingle/#channel-interceptors)を見ていきます。これらは、メッセージが入力チャンネルに当たる前に何かをすることを可能にします。これは、私が想定しているものは、channelOneです。ユースケースに応じて、メッセージを記録したり、例外をスローすることができます。

<channel id="channelOne"> 
    <interceptors> 
     <ref bean="yourValidatingInterceptor"/> 
    </interceptors> 
</channel> 

<beans:bean id="yourValidatingInterceptor" class="com.yourcompany.YourValidatingInterceptor"/> 
+0

現在のリリースは2.2.0です:http://static.springsource.org/spring-integration/docs/2.2.0.RELEASE/reference/htmlsingle/#channel-interceptors http://static.springsource.org/spring-integration/docs/latest-ga/reference/htmlsingle/#channel-interceptors –

+0

@GaryRussellがGaryに感謝しています。 – tjg184

10

チェーンは、エンドポイントがダイレクトチャネルによって接続されている場合の構成を簡素化するために便利です:

代わりの

<int:channel id="foo1"/> 

<int:service-activator input-channel="foo1" output-channel="foo2" ref="s1" /> 

<int:channel id="foo2"/> 

<int:service-activator input-channel="foo2" output-channel="foo3" ref="s2/> 

<int:channel id="foo3"/> 

<int:service-activator input-channel="foo3" output-channel="foo4" ref="s3" /> 

<int:channel id="foo4"/> 

あなたは

<int:channel id="foo1"/> 

<int:chain input-channel="foo1" output-channel="foo4">  
    <int:service-activator ref="s1" /> 
    <int:service-activator ref="s2" /> 
    <int:service-activator ref="s3" /> 
</int:chain> 

<int:channel id="foo4"/> 

を使用することができますcurrent documentationを使用してください。

1

メッセージハンドラチェーンハンドラのセットが線形に接続された である必要がある場合。上記の例では

<int:chain input-channel="marketDataInputChannel"> 
    <int:splitter ref="marketDataSplitter"/> 
    <int:service-activator ref="marketFieldServiceActivator"/> 
    <int:aggregator ref="marketDataAggregator"/> 
    <int:service-activator ref="marketItemServiceActivator"/> 
</int:chain> 

、チャネルスプリッタの出力データは入力 のサービスベーターなり、サービス活性化剤の出力は、アグリゲータの入力 あろう.. 。
私はこの説明のヘルプあなたは一般的に<int:chain />

+0

あなたはこのチェーンに定義された出力チャンネルを持っていません...私はこれを他の場所で見てきましたが、それが正当だと信じていますが、あなたの "marketItemServiceActivator"の出力はどこに行きますか? – HDave

関連する問題