этот код работает правильно: < /p>
Код: Выделить всё
private static RestTemplate pooledRestTemplate() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(2000);
connectionManager.setDefaultMaxPerRoute(2000);
HttpClient httpClient =
HttpClientBuilder.create().setConnectionManager(connectionManager).build();
return new RestTemplateBuilder()
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(httpClient))
.setConnectTimeout(Duration.ofMinutes(5))
.build();
}
Код: Выделить всё
return new RestTemplateBuilder()
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(httpClient))
.setConnectTimeout(Duration.ofMinutes(5))
.setReadTimeout(Duration.ofMinutes(5))
.build();
< /code>
Когда начинается приложение, появляется сообщение об ошибке: < /p>
java.lang.IllegalStateException: Request factory org.springframework.http.client.HttpComponentsClientHttpRequestFactory has the setReadTimeout method marked as deprecated
, но я не понял Как объединить пул разъемов и ResttemplateBuilder.
Подробнее здесь: https://stackoverflow.com/questions/774 ... eadtimeout
Мобильная версия