hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Check Peck <comptechge...@gmail.com>
Subject How to use PoolingHttpClientConnectionManager and other things in older version of Apache http client?
Date Tue, 04 Aug 2015 18:42:33 GMT
I am using Apache HttpClient 4.2.5 which is very old and we cannot update
as of now due to old legacy system we have. In my other project in which I
am using Apache HttpClient 4.3.1, I am using below code:

    private ClientHttpRequestFactory clientHttpRequestFactory() {
        HttpComponentsClientHttpRequestFactory requestFactory = new
HttpComponentsClientHttpRequestFactory();
        RequestConfig requestConfig =
RequestConfig.custom().setConnectionRequestTimeout(1000).setConnectTimeout(1000)

.setSocketTimeout(1000).setStaleConnectionCheckEnabled(false).build();
        SocketConfig socketConfig =
SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build();

        PoolingHttpClientConnectionManager
poolingHttpClientConnectionManager = new
PoolingHttpClientConnectionManager();
        poolingHttpClientConnectionManager.setMaxTotal(300);
        poolingHttpClientConnectionManager.setDefaultMaxPerRoute(200);

        CloseableHttpClient httpClientBuilder = HttpClientBuilder.create()

.setConnectionManager(poolingHttpClientConnectionManager).setDefaultRequestConfig(requestConfig)
                .setDefaultSocketConfig(socketConfig).build();

        requestFactory.setHttpClient(httpClientBuilder);
        return requestFactory;
    }

I cannot use same above code in my legacy code in which I have 4.2.5 Apache
HttpClient. I cannot find RequestConfig and SocketConfig. Is there any
other way to achieve the above thing in 4.2.5 Apache HttpClient?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message