List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager setParams
public void setParams(HttpConnectionManagerParams paramHttpConnectionManagerParams)
From source file:org.wso2.carbon.micro.integrator.core.internal.ServiceComponent.java
private ConfigurationContext getClientConfigurationContext() throws AxisFault { String clientRepositoryLocation = serverConfig.getFirstProperty(CLIENT_REPOSITORY_LOCATION); String clientAxis2XmlLocationn = serverConfig.getFirstProperty(CLIENT_AXIS2_XML_LOCATION); ConfigurationContext clientConfigContextToReturn = ConfigurationContextFactory .createConfigurationContextFromFileSystem(clientRepositoryLocation, clientAxis2XmlLocationn); MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); // Set the default max connections per host int defaultMaxConnPerHost = 500; Parameter defaultMaxConnPerHostParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("defaultMaxConnPerHost"); if (defaultMaxConnPerHostParam != null) { defaultMaxConnPerHost = Integer.parseInt((String) defaultMaxConnPerHostParam.getValue()); }/*from w ww . j av a 2 s . c om*/ params.setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); // Set the max total connections int maxTotalConnections = 15000; Parameter maxTotalConnectionsParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("maxTotalConnections"); if (maxTotalConnectionsParam != null) { maxTotalConnections = Integer.parseInt((String) maxTotalConnectionsParam.getValue()); } params.setMaxTotalConnections(maxTotalConnections); params.setSoTimeout(600000); params.setConnectionTimeout(600000); httpConnectionManager.setParams(params); clientConfigContextToReturn.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, httpConnectionManager); // registerHouseKeepingTask(clientConfigContextToReturn); clientConfigContextToReturn.setProperty(ServerConstants.WORK_DIR, serverWorkDir); return clientConfigContextToReturn; }
From source file:org.wso2.esb.integration.common.utils.clients.axis2client.ConfigurationContextProvider.java
public ConfigurationContextProvider() { try {// w ww .j a va2s . com MultiThreadedHttpConnectionManager httpConnectionManager; HttpClient httpClient; HttpConnectionManagerParams params; configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( TestConfigurationProvider.getResourceLocation() + File.separator + "client", null); httpConnectionManager = new MultiThreadedHttpConnectionManager(); params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(25); httpConnectionManager.setParams(params); httpClient = new HttpClient(httpConnectionManager); configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE); } catch (AxisFault axisFault) { log.error(axisFault); } }