Reputation: 195
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?
Upvotes: 1
Views: 2236
Reputation: 121552
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.
Upvotes: 4