Special Channels
默认情况下,应用程序上下文中定义了两个特殊通道:errorChannel
和 nullChannel
。'nullChannel'(NullChannel
的实例)的作用类似于 /dev/null
,它会记录发送到它的任何消息(DEBUG
级别的),并立即返回。此特别处理用于发送消息的 org.reactivestreams.Publisher
有效负载:它会在该通道中立即订阅,以启动 Reactive Stream 处理,尽管数据会被丢弃。Reactive Stream 处理中出现的错误(参见 Subscriber.onError(Throwable)
)会记录在 warn
级别,以便进行可能的调查。如果需要处理此类错误,可以将带有 Mono.doOnError()
自定义的 ReactiveRequestHandlerAdvice
应用到消息处理器,生成 Mono
回复,并将其发送至此 nullChannel
。每次您遇到您不关心的回复的通道解析错误时,都可以将受影响的组件的 output-channel
属性设置为 'nullChannel'(名称 'nullChannel' 在应用程序上下文中被保留)。
Two special channels are defined within the application context by default: errorChannel
and nullChannel
.
The 'nullChannel' (an instance of NullChannel
) acts like /dev/null
, logging any message sent to it at the DEBUG
level and returning immediately.
The special treatment is applied for an org.reactivestreams.Publisher
payload of a transmitted message: it is subscribed to in this channel immediately, to initiate reactive stream processing, although the data is discarded.
An error thrown from a reactive stream processing (see Subscriber.onError(Throwable)
) is logged under the warn
level for possible investigation.
If there is need to do anything with such an error, the ReactiveRequestHandlerAdvice
with a Mono.doOnError()
customization can be applied to the message handler producing Mono
reply into this nullChannel
.
Any time you face channel resolution errors for a reply that you do not care about, you can set the affected component’s output-channel
attribute to 'nullChannel' (the name, 'nullChannel', is reserved within the application context).
“errorChannel” 在内部用于发送错误消息,并且可以使用自定义配置进行覆盖。在 Error Handling 中更详细地讨论了这一点。
The 'errorChannel' is used internally for sending error messages and may be overridden with a custom configuration. This is discussed in greater detail in Error Handling.
另请参见 Java DSL 一章中的 Message Channels,以了解有关消息通道和拦截器的更多信息。
See also Message Channels in the Java DSL chapter for more information about message channel and interceptors.