私はApache PoolingHttpClientConnectionManagerを使用して会議のプールを作成しています。しかし、私は、既存のアイドル接続が使用されておらず、新しい接続を作成することをログで確認しています。応答がPoolStatsを受信した後、以下のコードPoolingHttpClientConnectionManagerが既存のアイドル接続を再使用しない
PoolingHttpClientConnectionManager connManager = connManager = new PoolingHttpClientConnectionManager();
connManager.setMaxTotal(4);
connManager.setDefaultMaxPerRoute(4);
//Creating CloseableHttpClient with a default keep alive of 2 minutes
CloseableHttpClient client = HttpClients.custom()
.setConnectionManager(connManager)
.setKeepAliveStrategy(new KeepAliveStrategy(keepAlive))
.build();
//Sending 1st request
String xml="<xml data>";
HttpPost post = new HttpPost("<URL>");
HttpEntity entity = new ByteArrayEntity(xml.getBytes("UTF-8"));
post.setEntity(entity);
HttpResponse response =client.execute(post);
String result = EntityUtils.toString(response.getEntity());
EntityUtils.consume(response.getEntity());
がある利用可能な接続の総数は1であることを述べています。
今、私は再び5秒後に同じ要求を火災やレスポンスにが利用可能な接続の総数はPoolStats
のために2以下のコードであることを述べてPoolStatsを取得したとき
PoolStats stats = connManager.getTotalStats(); System.out.println("Total Connections Available : "+stats.getAvailable());
ここで私の質問は最初のリクエストレスポンスの後にすでにConnectionがプールにあったので、なぜそれが作成されたのですか?もう1つの接続。なぜそれは既存の議会を使用しなかったのですか?