Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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());
- PoolStats stats = connManager.getTotalStats();
- System.out.println("Total Connections Available : "+stats.getAvailable());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement