Reputation: 12621
I am new to spring integration. i have few channels configured in my configuration file as below.
<int:channel id="channelOne" />
<int:channel id="channelTwo" />
<int:channel id="channelThree" />
can i use MessageHandlerChain ( http://static.springsource.org/spring-integration/docs/2.0.0.RC1/reference/html/chain.html ) in this scenario?
Thanks!
Upvotes: 6
Views: 14041
Reputation: 174749
A chain is a convenience to simplify configuration when endpoints are connected by direct channels:
Instead of
<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"/>
You can use
<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"/>
Please use the current documentation.
Upvotes: 14
Reputation: 6300
we use Message Handler Chain when a set of handlers needs to be connected in a linear fashion.
<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>
in the example above, the output data of channel splitter will be the input
of service-activator, and the output of service-activator will be the input
of aggregator ...
I hope that this explanation help you to understand the utility of <int:chain />
Upvotes: 1
Reputation: 4686
I would take a look at channel interceptors (http://static.springsource.org/spring-integration/docs/latest-ga/reference/htmlsingle/#channel-interceptors). These would allow you to do something prior to the message hitting your input channel, which I assume is channelOne. You could log a message or throw an exception, etc. depending on your use case.
<channel id="channelOne">
<interceptors>
<ref bean="yourValidatingInterceptor"/>
</interceptors>
</channel>
<beans:bean id="yourValidatingInterceptor" class="com.yourcompany.YourValidatingInterceptor"/>
Upvotes: 3