带条件的 http 出站重试(用于检查器条件) [英] http outbound retry with conditions (For checker condition)
问题描述
我想使用重试条件进行 http 出站网关调用.出站网关将重试,直到我返回 ERROR 或 COMPLETE 的其余 API.
我所做的是:
然后是路由器
@Router(inputChannel = "checkJobChannel.reply",applySequence = "true")public String pointJob(Message>reply) {字符串 returnChannel="";if(reply.getPayload().get("status").equals("RUNNING")){returnChannel="checkJobChannel";}else if(reply.getPayload().get("status").equals("COMPLETE")|reply.getPayload().get("status").equals("ERROR")){returnChannel="nextChannel";}返回returnChannel;}
我可以这样做吗?谢谢.实现这一目标的简单方法是什么?
看起来不错.如果您没有从该 REST 服务返回任何异常,那么您使用路由器的简单方法对我来说看起来不错.
您只需要注意有一个RequestHandlerRetryAdvice
,您可以将其放入
以隔离逻辑.>
此外,您可以考虑到 RequestHandlerCircuitBreakerAdvice
不会根据某些条件调用您的 REST 服务.
但是由于您在那里没有例外,您将需要针对这些模式的要求提出一些支柱".
您可以在 参考手册.
I want to make http outbound gateway call with retry condition. The outbound gateway will retry until the rest API that i have return ERROR or COMPLETE.
What i do is:
<int-http:outbound-gateway request-channel="checkJobChannel"
url="http://host/rest/job-status"
http-method="GET"
extract-request-payload="true"
expected-response-type="java.lang.String"
reply-timeout="10000"
reply-channel="checkJobChannel.reply"
auto-startup="true"
transfer-cookies="true">
then the router
@Router(inputChannel = "checkJobChannel.reply",applySequence = "true")
public String pointJob(Message<?>reply) {
String returnChannel ="";
if(reply.getPayload().get("status").equals("RUNNING")){
returnChannel="checkJobChannel";
}else if(reply.getPayload().get("status").equals("COMPLETE")|reply.getPayload().get("status").equals("ERROR")){
returnChannel="nextChannel";
}
return returnChannel;
}
Can I do like that? Thanks. What the simple way to achieve that?
Looks like that is good one. If you don't have any exceptions in return from that REST service, your simple approach with the router looks good to me.
You only can pay attention that there is a RequestHandlerRetryAdvice
which you can place into your <int-http:outbound-gateway>
to isolate the logic.
In addition you can take into account the RequestHandlerCircuitBreakerAdvice
do not invoke your REST service according some condition.
But since you don't have an exception there, you will need to come up with some "struts" to requirements of those patterns.
You can find more info on the matter in the Reference Manual.
这篇关于带条件的 http 出站重试(用于检查器条件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!