1
我有下面的代码来调用使用Apache HTTP客户端的REST API方法。但是只有两个并行请求可以使用上面的客户端发送。 是否有任何参数设置最大连接?Apache HTTP客户端只有两个连接是可能的
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
感谢您的回答。还有一个问题。如果使用池连接管理器,我们不必在下面执行GET或POST时关闭连接,是吗? HttpPost post = new HttpPost(resourcePath); try { return httpClient.execute(post); } catch(IOException e){ //处理异常 } finally { post.releaseConnection(); } – 2014-10-08 09:52:52
@ UdaraS.SLiyanage希望你得到它的工作:-) – 2014-10-08 09:53:34