multithreading - Java HttpClient number of Connections to a host -
multithreading - Java HttpClient number of Connections to a host -
i have httpclient initiating requests web application. using httpcomponents apache library.
i set connection manager below.
public synchronized static void registercnalhttpclient(final parameters params) { final int maxtotalconnections = integer.valueof(params.get("max_total_connections", "100")); final int defaultmaxconnectionsperhost = integer.valueof(params.get("def_max_connections_per_host", "50")); final poolinghttpclientconnectionmanager connectionmanager = new poolinghttpclientconnectionmanager(); connectionmanager.setmaxtotal(maxtotalconnections); connectionmanager.setdefaultmaxperroute(defaultmaxconnectionsperhost); final httpclientbuilder httpclientbuilder = httpclients.custom(); httpclientbuilder.setconnectionmanager(connectionmanager); httpclient = httpclientbuilder.build(); esb.put(cnal_httpclient_str, httpclient); } }
however netstat linux server running httpclient application never see more 13 connections server issue request to.
am doing wrongly here? application multithreaded 1 why went poolinghttpclientconnectionmanager() class.
for completeness code below shows how utilize httpclient create requests
final httpget httpget = new httpget(uri); httpget.setconfig(requestconfig); seek { final closeablehttpresponse closeablehttpresponse = cnalhttpclient.execute(httpget); seek { final httpentity responseentity = closeablehttpresponse.getentity(); if (responseentity != null) { final inputstream = responseentity.getcontent(); final contenttype contenttype = contenttype.getordefault(responseentity); final charset charset = contenttype.getcharset(); response = ioutils.tostring(is, charset); final map<string, string> m = projectstringutils.spliturlquery(response.trim()); ... }catch(...) { seek { closeablehttpresponse.close(); } grab (ioexception e) { } } catch(...)
i expect have around 200 connections since def_max_connections_per_host have set. guys hosting application sending requests not limit concurrent connections allowed end.
any ideas?
java multithreading http apache-httpclient-4.x
Comments
Post a Comment