actually i'am migration from springboot 2 to 3 and i'am struggling in httpClient configuration of spring WebClient and my question is :
which http client to use ? java 17 net.httpClient , netty reactor , or could we keep apache http client . I need to keep ssl , caching mecanism and pooling, but in netty we don't have all these features , here is a code snippet of my configuration with springboot 2 :
return new RestTemplateBuilder()
.requestFactory(() -> {
CacheConfig cacheConfig = CacheConfig.custom()
.setMaxCacheEntries(100)
.build();
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5000, TimeUnit.MILLISECONDS)
.setSocketTimeout(5000,TimeUnit.MILLISECONDS)
.build();
HttpClientBuilder httpClientBuilder = CachingHttpClients.custom()
.setCacheConfig(cacheConfig)
.setDefaultRequestConfig(requestConfig);
SslStore truststore = backendProperties.getTruststore();
SslStore keystore = backendProperties.getKeystore();
if (truststore != null && truststore.getPath() != null && keystore != null && keystore.getPath() != null) {
LayeredConnectionSocketFactory sslSocketFactory = SslUtils.readSSLSocketFactory(truststore.getPath(), truststore.getPassword(), keystore.getPath(), keystore.getPassword());
if (sslSocketFactory != null) {
httpClientBuilder.setSSLSocketFactory(sslSocketFactory);
}
}
HttpClient client = httpClientBuilder.build();
return new HttpComponentsClientHttpRequestFactory(client);
})
.build();
thanks