I need to add a router in Spring integration application. The requirement is to either to send the message by the router to both the channel or to a single channel based on the return string sent by the router class. please tell me how to route the message to both the channels.
-
Your question is not clear. Please read the chapter on routers and come back if you have a specific question.Gary Russell– Gary Russell2015-10-19 13:14:27 +00:00Commented Oct 19, 2015 at 13:14
-
Hi Gary Russell. The doubt is : A Router can direct the message to single or multiple channels based on the condition. I could not find out how to send message to more than one channel under one condition. let say if the bean returns the value "A" I need to send the message to Channel-A and if the bean returns value "B" need to send the message to Channel-A and Channel-B both. The bean decides to send "A" or "B" based on payload parameter. Can this be done using the router alone.if yes,then how do I define Channel-A and Channel-B (both) on return of value "B". An XML example will be helpfulMegan– Megan2015-10-19 22:49:52 +00:00Commented Oct 19, 2015 at 22:49
-
I returned a collection of channels from the bean. So it worked now.Megan– Megan2015-10-19 23:58:29 +00:00Commented Oct 19, 2015 at 23:58
Add a comment
|
1 Answer
You can use the combination of a Splitter and a Header Value Router to duplicate and route messages.
<!-- Clone message -->
<int:splitter ref="messageDuplicator" method="duplicateMessage"
input-channel="incomingMessage" output-channel="duplicateMessageChannel" id="messageSplitter"/>
<int:header-value-router input-channel="duplicateMessageChannel" header-name="DESTINATION" id="messageDestinationRouter">
<int:mapping value="DEST_1" channel="dest1Channel" />
<int:mapping value="DEST_2" channel="dest2Channel" />
</int:header-value-router>
In your messageDuplicator implementation, you can add code to clone your message and add custom headers for routing the message to different destinations.