为端点添加行为
在 Spring Integration 2.2 之前,您可以通过向轮询器的 <advice-chain/> 元素添加 AOP 建议来向整个集成流添加行为。但是,假设您只想重试(例如)一个 REST Web 服务调用,而不重试任何下游端点。
例如,考虑以下流程
inbound-adapter->poller->http-gateway1->http-gateway2->jdbc-outbound-adapter
如果您在轮询器的建议链中配置了一些重试逻辑,并且由于网络故障导致对 http-gateway2 的调用失败,则重试将导致 http-gateway1 和 http-gateway2 都被第二次调用。类似地,在 jdbc-outbound-adapter 中发生瞬时故障后,两个 HTTP 网关都会被第二次调用,然后再次调用 jdbc-outbound-adapter。
Spring Integration 2.2 增加了向单个端点添加行为的能力。这通过向许多端点添加 <request-handler-advice-chain/> 元素来实现。以下示例展示了如何在 outbound-gateway 中使用 <request-handler-advice-chain/> 元素
<int-http:outbound-gateway id="withAdvice"
url-expression="'https:///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 之后不适用于下游采取的进一步操作。建议的范围仅限于端点本身。
|
目前,您无法建议整个端点 但是,可以将 |