0

每当我在 Spring 启动时在我的 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);
4

1 回答 1

0

Apache 的 HttpClient 的连接池默认只能同时打开两个连接。

为了能够执行更多请求,必须关闭响应对象才能再次释放与池的连接。

更多信息可以在这里找到:http: //hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

于 2019-03-28T15:38:15.287 回答