|
|
@ -9,19 +9,22 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
|
|
|
public class SeaweedUtil { |
|
|
|
|
|
|
|
static PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); |
|
|
|
static CloseableHttpClient httpClient; |
|
|
|
|
|
|
|
static { |
|
|
|
// Increase max total connection to 200 |
|
|
|
cm.setMaxTotal(200); |
|
|
|
// Increase default max connection per route to 20 |
|
|
|
cm.setDefaultMaxPerRoute(20); |
|
|
|
} |
|
|
|
|
|
|
|
public static CloseableHttpClient getClosableHttpClient() { |
|
|
|
return HttpClientBuilder.create() |
|
|
|
httpClient = HttpClientBuilder.create() |
|
|
|
.setConnectionManager(cm) |
|
|
|
.setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE) |
|
|
|
.setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE) |
|
|
|
.build(); |
|
|
|
} |
|
|
|
|
|
|
|
public static CloseableHttpClient getClosableHttpClient() { |
|
|
|
return httpClient; |
|
|
|
} |
|
|
|
} |