How to handle subflows

拈花ヽ惹草 提交于 2019-12-11 10:23:19

问题


Can we use somehow "subflows" in Spring Integration?

I have many different processes which would use the same "subflow". These processes have always the same part which would be good to be put into a separate file.

What would be the corrent way to implement these flows?

I tried to find a solution to use subflows in Spring Integration but I could not find anything.


回答1:


One simple technique is to put the subflow in a separate file with "well-known" input and output channels (the subflow starts with one channel and ends with another). Then, simply <import/> the subflow and send/consume to/from the input/output channel.

Or, instead of an import you can use the Java DSL to define the subflow and add it to your application contexts that need the subflow...

@Configuration
public class MySubflowDefinition {

    @Bean
    public IntegrationFlow subflow() {
        return IntegrationFlows.from("someInChannel")
           .transform(...)
           ...
           .channel("someOutChannel")
           .get();
    }
}

For a more formal "subflow" definition, see the spring-integration-flow extension. This solution also allows the same subflow to be invoked from multiple places in the same application context.

spring-integration-java-dsl and spring-integration-flow are both available in the spring repo and maven central with (currently) versions 1.0.0.RELEASE.



来源:https://stackoverflow.com/questions/27306239/how-to-handle-subflows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!