[英]Handle more then two requests simultaneously with HttpClient
每當我在Spring Boot的restcontroller中的一個getmapping方法中使用以下調用時,就永遠不會執行。 當我注釋掉三個中的一個時,它非常有效。 不管是哪種組合,它們都可以工作,但最多只能有兩個。
HttpGet httpget1 = new HttpGet(url+"api/now/table/incident?assignment_group=FS_logistic&incident_state=1");
httpget1.setHeader("Accept", "application/json");
CloseableHttpResponse response1 = httpclient.execute(httpget1);
HttpGet httpget2 = new HttpGet(url+"api/now/table/incident?assignment_group=FS_logistic&incident_state=2");
httpget2.setHeader("Accept", "application/json");
CloseableHttpResponse response2 = httpclient.execute(httpget2);
HttpGet httpget3 = new HttpGet(url+"api/now/table/incident?assignment_group=FS_logistic&incident_state=3");
httpget3.setHeader("Accept", "application/json");
CloseableHttpResponse response3 = httpclient.execute(httpget3);
默認情況下,Apache HttpClient的連接池只能同時打開兩個連接。
為了能夠執行更多請求,必須關閉響應對象才能再次釋放與池的連接。
可以在這里找到更多信息: http : //hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.