在Spring Webflow中阻止读取5000毫秒的超时 [英] Timeout on blocking read for 5000 MILLISECONDS in Spring Webflux

查看:13
本文介绍了在Spring Webflow中阻止读取5000毫秒的超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Handler(Spring Webflow)编写了一个测试

@Test
public void checkServicesHandlerTest() {
    Request request = new Request();
    request.setMsisdn("ffdfdfd");
    this.testClient.post().uri("/check")
                   .body(Mono.just(request), Request.class)
                   .exchange().expectStatus().isOk();
}

但在结果中我出错。

Timeout on blocking read for 5000 MILLISECONDS

处理程序很简单:

 public Mono<ServerResponse> check(ServerRequest request) {
       
     Request request = request.bodyToMono(Request.class).block();

问题出在哪里?如果我向服务器发送直接请求,则一切正常。

推荐答案

我在运行集成测试时看到了类似的问题和异常,其中一些测试聚合了来自具有数据库访问权限的多个其他服务的响应。因此,在运行集成测试时,我们会间歇性地看到这个问题。我们在Gradle上使用了Spring Boot 2.0.0.RC1和JUnit5。我这样做是为了解决这个问题。关键是改变Web客户端,最坏的情况是响应超时30秒。

@Autowired
private WebTestClient webTestClient;

@BeforeEach
public void setUp() {
    webTestClient = webTestClient.mutate()
                                 .responseTimeout(Duration.ofMillis(30000))
                                 .build();
}

这篇关于在Spring Webflow中阻止读取5000毫秒的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆