private CloseableHttpAsyncClient createClient ( HttpSettings settings , ApacheHttpClientConfiguration conf ) { IOReactorConfig ioReactor = IOReactorConfig . custom ( ) . setIoThreadCount ( conf . getMaxThreadCount ( ) ) . build ( ) ; HttpAsyncClientBuilder httpClientBuilder = HttpAsyncClients . custom ( ) . useSystemProperties ( ) // allow POST redirects . setRedirectStrategy ( new LaxRedirectStrategy ( ) ) . setMaxConnTotal ( conf . getMaxTotalConnectionCount ( ) ) . setMaxConnPerRoute ( conf . getMaxRouteConnectionCount ( ) ) . setDefaultIOReactorConfig ( ioReactor ) . setKeepAliveStrategy ( new DefaultConnectionKeepAliveStrategy ( ) ) . setDefaultRequestConfig ( createDefaultRequestConfig ( settings ) ) ; if ( settings . getProxyUrl ( ) != null ) { DefaultProxyRoutePlanner routePlanner = createProxyRoutePlanner ( settings , httpClientBuilder ) ; httpClientBuilder . setRoutePlanner ( routePlanner ) ; } CloseableHttpAsyncClient httpClient = httpClientBuilder . build ( ) ; httpClient . start ( ) ; return httpClient ; }
Creates asynchronous Apache HTTP client .