对于最新的稳定版本,请使用 Spring Integration 6.4.3! |
向终端节点添加行为
在 Spring Integration 2.2 之前,你可以通过将 AOP Advice 添加到 Poller 的<advice-chain/>
元素。
但是,假设您只想重试 REST Web 服务调用,而不重试任何下游终端节点。
例如,请考虑以程:
inbound-adapter->poller->http-gateway1->http-gateway2->jdbc-outbound-adapter
如果你在 Poller 上将一些 retry-logic 配置到通知链中,并且调用http-gateway2
由于网络故障而失败,则重试会导致http-gateway1
和http-gateway2
以第二次调用。
同样,在 jdbc-outbound-adapter 中出现暂时性故障后,两个 HTTP 网关都会被第二次调用,然后再次调用jdbc-outbound-adapter
.
Spring Integration 2.2 增加了向单个端点添加行为的能力。
这是通过添加<request-handler-advice-chain/>
元素添加到多个端点。
以下示例显示了如何<request-handler-advice-chain/>
元素中outbound-gateway
:
<int-http:outbound-gateway id="withAdvice"
url-expression="'http://localhost/test1'"
request-channel="requests"
reply-channel="nextChannel">
<int-http:request-handler-advice-chain>
<ref bean="myRetryAdvice" />
</int-http:request-handler-advice-chain>
</int-http:outbound-gateway>
在这种情况下,myRetryAdvice
仅在本地应用于此网关,不适用于在将回复发送到nextChannel
.
建议的范围仅限于终端节点本身。
此时,您无法建议整个 但是, |