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