我有以下代码,使用Apache HTTP客户端调用REST API方法。然而,仅可以使用上述客户端发送两个并行请求。是否有参数可设置最大连接数?
HttpPost post = new HttpPost(resourcePath);
addPayloadJsonString(payload, post);//set a String Entity
setAuthHeader(post);// set Authorization: Basic header
try {
return httpClient.execute(post);
} catch (IOException e) {
String errorMsg = "Error while executing POST statement";
log.error(errorMsg, e);
throw new RestClientException(errorMsg, e);
}
我正在使用的罐子如下:
org.apache.httpcomponents.httpclient_4.3.5.jar
org.apache.httpcomponents.httpcore_4.3.2.jar
try { return httpClient.execute(post);
} catch (IOException e) { //处理异常 }finally { post.releaseConnection(); }
- Udara S.S Liyanage