Warm tip: This article is reproduced from stackoverflow.com, please click
java spring spring-integration

Cancel execution flow in Spring Integration

发布于 2020-03-27 10:20:19

I have the following case: in my app I need to interrupt the flow execution. There is a chain with a set of methods calls. How can I cancel the this methods set execution? Throwing exception is not an option in this case (It's a legacy project and exceptions are handled in some Aspect, it's better to avoid touching this code so far). Insert smth. like a filter after each method call?

Artem Bilan 2019-07-03 21:59

You can have something like global ChannelInterceptor with a pattern to match for desired channels to check the state for possible interruption behavior.

See documentation for more info: https://docs.spring.io/spring-integration/docs/5.1.6.RELEASE/reference/html/#channel-interceptors

This is some kind of Aspect as well, but in terms of Spring Integration and EIP.