Overview
路由器是许多消息架构中的关键元素。它们从消息通道中使用消息,根据一组条件将每个使用过的消息转发到一个或更多不同的消息通道。
Routers are a crucial element in many messaging architectures. They consume messages from a message channel and forward each consumed message to one or more different message channels depending on a set of conditions.
Spring Integration 提供以下路由器:
Spring Integration provides the following routers:
路由器实现共享许多配置参数。但是,路由器之间存在某些差异。此外,配置参数的可用性取决于路由器是在链内还是链外使用。为了提供快速概述,所有可用的属性都列在以下两个表中。
Router implementations share many configuration parameters. However, certain differences exist between routers. Furthermore, the availability of configuration parameters depends on whether routers are used inside or outside a chain. In order to provide a quick overview, all available attributes are listed in the two following tables .
下表显示了用于链外路由器的配置参数:
The following table shows the configuration parameters available for a router outside a chain:
Attribute | router | header value router | xpath router | payload type router | recipient list route | exception type router |
---|---|---|---|---|---|---|
apply-sequence |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
default-output-channel |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
resolution-required |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
ignore-send-failures |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
timeout |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
id |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
auto-startup |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
input-channel |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
order |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
method |
image::tickmark.png[] |
|||||
ref |
image::tickmark.png[] |
|||||
expression |
image::tickmark.png[] |
|||||
header-name |
image::tickmark.png[] |
|||||
evaluate-as-string |
image::tickmark.png[] |
|||||
xpath-expression-ref |
image::tickmark.png[] |
|||||
converter |
image::tickmark.png[] |
下表显示了用于链内路由器的配置参数:
The following table shows the configuration parameters available for a router inside a chain:
Attribute | router | header value router | xpath router | payload type router | recipient list router | exception type router |
---|---|---|---|---|---|---|
apply-sequence |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
default-output-channel |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
resolution-required |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
ignore-send-failures |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
timeout |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
image::tickmark.png[] |
id |
||||||
auto-startup |
||||||
input-channel |
||||||
order |
||||||
method |
image::tickmark.png[] |
|||||
ref |
image::tickmark.png[] |
|||||
expression |
image::tickmark.png[] |
|||||
header-name |
image::tickmark.png[] |
|||||
evaluate-as-string |
image::tickmark.png[] |
|||||
xpath-expression-ref |
image::tickmark.png[] |
|||||
converter |
image::tickmark.png[] |
自 Spring Integration 2.1 起,路由器参数已在所有路由器实现中进行了更标准化的处理。因此,一些细微的更改可能会破坏基于旧版 Spring Integration 的应用程序。
As of Spring Integration 2.1, router parameters have been more standardized across all router implementations. Consequently, a few minor changes may break older Spring Integration based applications.
自 Spring Integration 2.1 起,ignore-channel-name-resolution-failures
属性已被弃用,有利于将其行为与 resolution-required
属性合并。同时,resolution-required
属性现在默认为 true
。
Since Spring Integration 2.1, the ignore-channel-name-resolution-failures
attribute is removed in favor of consolidating its behavior with the resolution-required
attribute.
Also, the resolution-required
attribute now defaults to true
.
在进行这些更改之前,resolution-required
属性默认为 false
,这会导致在未解析出任何信道并且未设置 default-output-channel
时,消息被静默丢弃。新行为需要至少有一个已解析的信道,并且默认情况下,如果未确定信道(或发送尝试不成功),将抛出 MessageDeliveryException
。
Prior to these changes, the resolution-required
attribute defaulted to false
, causing messages to be silently dropped when no channel was resolved and no default-output-channel
was set.
The new behavior requires at least one resolved channel and, by default, throws a MessageDeliveryException
if no channel was determined (or an attempt to send was not successful).
如果你确实想静默丢弃消息,可以设置 default-output-channel="nullChannel"
。
If you do desire to drop messages silently, you can set default-output-channel="nullChannel"
.