0

我对不同的 api 有两个相互依赖的 webclient 调用,当第一个 webclient 调用响应被延迟时,readtimeout excpetion 即将到来。但是每当第一个呼叫成功并且第二个呼叫响应被延迟时,它就会无限期地等待响应。

我尝试为每个调用创建单独的 webclient 实例。问题仍然存在。

HttpClient httpClient = HttpClient.create()
            .tcpConfiguration(client ->

                    client.doOnConnected(conn -> conn
                            .addHandlerLast(new ReadTimeoutHandler(10))
                            .addHandlerLast(new WriteTimeoutHandler(10))));


    return WebClient.builder().baseUrl(url).clientConnector(new ReactorClientHttpConnector(httpClient))
            .exchangeStrategies(ExchangeStrategies.withDefaults())
            .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
            .filter(ExchangeFilterFunctions
                    .basicAuthentication(", "))
            .build();

两个后续调用低于 where ,当第二个调用延迟响应时,不会抛出 readtimeout 异常

request = request.flatMap(req ->
                tempService.getId(loggedInUser, token)
      .map(response -> {
                            req.setRetrieveClientIdentifier(response.getId());
                            return seRequest;
                        }))

                .zipWhen(request -> tempService.getIdFor(request.getIdentifier(), accountToken)).map(tuple -> {

                    tuple.getT1().setID(tuple.getT2().getId());
                    return tuple.getT1();
                });
4

0 回答 0