简体   繁体   English

Spring集成结束了流程

[英]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. 我正在从事Spring集成项目,目前在某些情况下我们使用return null结束流程。 Generally return null is not a good practice, I am looking for an alternate. 通常返回null不是一个好习惯,我正在寻找替代方法。 I tried with throwing exception for stopping the flow which i believed better than returning null. 我尝试抛出异常来停止流,我认为这比返回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? 但是在某些情况下,单个发布-订阅通道中会有两个流,在这种情况下,抛出异常会阻止这两个流。是否有更好的方法来停止SI中的流?

As you said: return null . 如您所说:返回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. 有一种方法可以按某种条件(您决定返回null )将其路由到出站通道适配器,这是一种单向组件,因此流程结束。 But this is going to be too wordy. 但这太罗word了。 Although in the future you will have a flexibility to do anything else in this null case. 尽管将来您可以在这种null情况下灵活地执行其他任何操作。

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. 但是,仍然可以在该通道上使用执行程序时执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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