对于最新的稳定版本,请使用 Spring Integration 6.5.1spring-doc.cadn.net.cn

运算符 intercept()

从 5.3 版开始,intercept()运算符允许注册一个或多个ChannelInterceptor实例在当前MessageChannel在流动中。 这是创建显式MessageChannel通过MessageChannels应用程序接口。 以下示例使用MessageSelectingInterceptor要拒绝某些邮件并出现异常:spring-doc.cadn.net.cn

.transform(...)
.intercept(new MessageSelectingInterceptor(m -> m.getPayload().isValid()))
.handle(...)