Operator intercept()

从 5.3 版开始,intercept() 运算符允许在流中的当前 MessageChannel 中注册一个或多个 ChannelInterceptor 实例。这是一种通过 MessageChannels API 创建显式 MessageChannel 的替代方法。以下示例使用了一个 MessageSelectingInterceptor 来拒绝带有异常的特定消息:

Starting with version 5.3, the intercept() operator allows to register one or more ChannelInterceptor instances at the current MessageChannel in the flow. This is an alternative to creating an explicit MessageChannel via the MessageChannels API. The following example uses a MessageSelectingInterceptor to reject certain messages with an exception:

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