Reputation: 33
I'm newbie in integration. I have a router. In a specific scenario, the method throws an exception. Based on that exception, how I can route my message.I want to catch that exception and based on route my message to another for example channel.
<integration:router ref="serviceImpl" method="getName"/>
Upvotes: 1
Views: 142
Reputation: 1391
You can try something like below:
First you configure the router and bean in the following manner:
<integration:router ref="serviceImpl" method="getName"/>
<beans:bean class="com.test.ServiceImpl" id="serviceImpl">
</beans:bean>
</int:router>
Then your ServiceImpl.java
should be something like below:
public class ServiceImpl {
public String getName(Name name) {
String channel = "";
try {
//Your business validations should be here and if everything is okay, then route the message to some channel
channel = "goToSomeChannel"
} catch (SomeException e) {
//You got the exception, So route to different channel
channel = "goToSomethingElseChannel";
}
return channel;
}
}
In the end you define both the channels goToSomeChannel
and goToSomethingElseChannel
in your spring integration configuration file.
Upvotes: 1