0

Whenever I have the following calls in one getmapping method in my restcontroller made in Spring boot, it never gets executed. It works perfectly when I comment out one out of the three. It doesn't matter which combination, they all work but maximum with two.

        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);
Ayoub Rossi
  • 410
  • 5
  • 18

1 Answers1

0

The connection pool for Apache's HttpClient can by default only have two connections open at the same time.

To be able to execute more requests it is mandatory to close the response objects in order to release a connection to the pool again.

More information can be found here: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

Ayoub Rossi
  • 410
  • 5
  • 18