Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在Spring集成中重试对Webflux.outboundgateway的失败调用_Spring Boot_Spring Integration_Spring Integration Dsl - Fatal编程技术网

Spring boot 如何在Spring集成中重试对Webflux.outboundgateway的失败调用

Spring boot 如何在Spring集成中重试对Webflux.outboundgateway的失败调用,spring-boot,spring-integration,spring-integration-dsl,Spring Boot,Spring Integration,Spring Integration Dsl,我在flow DSL语法中定义了一个spring集成流。我的一个处理程序是Webflux.outboundGateway。当远程URI不可访问时,将引发异常并发送到“errorChannel”。我正在尝试让流重试,但到目前为止没有成功(调用从未重试)。以下是我的配置: @Bean 公共集成流可检索流(){ 返回积分流 .来自(…) .处理( WebFlux.outboundGateway(m-> UriComponentsBuilder.fromURI字符串(remoteGateway+“/fo

我在flow DSL语法中定义了一个spring集成流。我的一个处理程序是Webflux.outboundGateway。当远程URI不可访问时,将引发异常并发送到“errorChannel”。我正在尝试让流重试,但到目前为止没有成功(调用从未重试)。以下是我的配置:

@Bean
公共集成流可检索流(){
返回积分流
.来自(…)
.处理(
WebFlux.outboundGateway(m->
UriComponentsBuilder.fromURI字符串(remoteGateway+“/foo/bar”)
.build()
.toUri(),网络客户端)
.httpMethod(httpMethod.POST)
.expectedResponseType(String.class)
.replyPayloadToFlux(true),e->e.advice(retryAdvice())
)
// [ ... ]
.get();
}
@豆子
公众意见{
RequestHandlerRetryAdvice=new RequestHandlerRetryAdvice();
RetryTemplate RetryTemplate=新RetryTemplate();
ExponentialBackOffPolicy retryPolicy=新的ExponentialBackOffPolicy();
retryPolicy.setInitialInterval(1000);
retryPolicy.setMaxInterval(20000);
retryTemplate.setBackOffPolicy(retryPolicy);
advice.setRetryTemplate(retryTemplate);
回信;
}

我应该使用不同于RequestHandlerRetryAdvice的东西吗?如果是,应该是什么?

Webflux根据定义是异步的,这意味着当请求完成/失败时,
Mono
(应答)是异步满足的,而不是在调用线程上。因此,建议不会有帮助,因为请求的“发送”部分总是成功的

您必须通过错误通道上的流执行重试(分配在流开始附近的某个位置)。可能有一些标题指示您重试了多少次

ErrorMessage
具有属性
failedMessage
cause
;您可以重新发送
失败消息


您可以关闭async以阻止调用线程,但这实际上违背了使用WebFlux的全部目的。

嗨,Gary,我有一个后续问题:我正试图实现与OP相同的功能,不同之处在于我有一个
Ftp.outboundGateway()
在其上执行
AbstractRemoteFileOutboundGateway.Command.GET
。我也有一个问题,我的重试建议从未在错误上执行过。我不太理解你关于异步满足回复的评论,但是这里的建议也可能永远不会执行吗?根据以下问题,我希望它能起作用:你不应该用一个新问题来评论一个已回答的问题。是,如果配置正确,将调用通知;FTP网关是同步的,因此不存在异步问题。提出新问题,显示您的配置。本周的答案将是零星的,因为我们是SpringOne平台会议。谢谢Gary,我发布了一个新问题。