简体   繁体   中英

Spring integration ending the flow

I am working on a spring integration project, currently we are using return null to end the flow in some instances. Generally return null is not a good practice, I am looking for an alternate. I tried with throwing exception for stopping the flow which i believed better than returning null. But in some cases there are two flows from single publish-subscribe-channel, in those cases throwing exception stops both the flow.Is there any better way to stop the flow in SI?

As you said: return null . There is the way to route by some condition (the same you decide to return null ) to the Outbound Channel Adapter what is a one-way component and therefore end of the flow. But this is going to be too wordy. Although in the future you will have a flexibility to do anything else in this null case.

Right, the exception way may cause unexpected behavior especially when you have a logic after first call, like in your publish-subscribe case. But still you can do that when you use an executor with that channel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM