I have a Spring Integration Flow Project that exposes a Rest Gateway, after receiving the Rest POST request, it does some minor logic. Based on some Payload parameters I would like to Activate another Spring Integration flow dynamically and route the message to a designated channel in that flow that I can discover in the Primary flow based on the Payload. The Sub flow will put the response message in a designated channel that is defined in the primary flow.
How can I achieve this.
Starting with version
1.2
Spring Integration Java DSL provides an API for runtime flow registration:So, according to your logic you can build and perform one flow or another.
Around that API you can even build some cache do not register the same flow several times, but just reuse after the first registration.
See the dynamic ftp example which uses a custom router to instantiate the sub flow and route to the new flow's channel.
Also see my answer to this question and its follow up for a similar mechanism, this time using java configuration for inbound mail adapters.