|
@@ -19,20 +19,15 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
*/
|
|
|
-public class HttpClientPool
|
|
|
-{
|
|
|
+public class HttpClientPool {
|
|
|
|
|
|
private static PoolingHttpClientConnectionManager cm = null;
|
|
|
|
|
|
- static
|
|
|
- {
|
|
|
+ static {
|
|
|
LayeredConnectionSocketFactory sslsf = null;
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
sslsf = new SSLConnectionSocketFactory(SSLContext.getDefault());
|
|
|
- }
|
|
|
- catch (NoSuchAlgorithmException e)
|
|
|
- {
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
@@ -40,8 +35,9 @@ public class HttpClientPool
|
|
|
.<ConnectionSocketFactory> create().register("https", sslsf)
|
|
|
.register("http", new PlainConnectionSocketFactory()).build();
|
|
|
cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
|
|
|
- cm.setMaxTotal(200);
|
|
|
- cm.setDefaultMaxPerRoute(20);
|
|
|
+ cm.setValidateAfterInactivity(1000);
|
|
|
+ cm.setMaxTotal(8000);
|
|
|
+ cm.setDefaultMaxPerRoute(50);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -50,9 +46,9 @@ public class HttpClientPool
|
|
|
* @author WANGWEI
|
|
|
* @return
|
|
|
*/
|
|
|
- public static CloseableHttpClient getHttpClient()
|
|
|
- {
|
|
|
- CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
|
|
|
+ public static CloseableHttpClient getHttpClient() {
|
|
|
+ CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
|
|
|
+ .disableAutomaticRetries().build();
|
|
|
return httpClient;
|
|
|
}
|
|
|
|