0

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.

3
  • Your question is not clear. Please read the chapter on routers and come back if you have a specific question. Commented 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 helpful Commented Oct 19, 2015 at 22:49
  • I returned a collection of channels from the bean. So it worked now. Commented Oct 19, 2015 at 23:58

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.