Example usage for org.apache.commons.httpclient MultiThreadedHttpConnectionManager setMaxConnectionsPerHost

List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager setMaxConnectionsPerHost

Introduction

In this page you can find the example usage for org.apache.commons.httpclient MultiThreadedHttpConnectionManager setMaxConnectionsPerHost.

Prototype

public void setMaxConnectionsPerHost(int paramInt) 

Source Link

Usage

From source file:org.activebpel.rt.axis.bpel.handlers.AeHTTPSender.java

/** @deprecated */
protected void initialize() {
    if (sConnectionManager == null) {
        synchronized (AeHTTPSender.class) {
            if (sConnectionManager == null) {
                // initialize the connection manager w/ its properties
                MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
                sClientProperties = CommonsHTTPClientPropertiesFactory.create();

                // max connections per host, defaults to constant above
                int maxConnectionsPerHost = getIntegerOption(
                        DefaultCommonsHTTPClientProperties.MAXIMUM_CONNECTIONS_PER_HOST_PROPERTY_KEY,
                        DEFAULT_MAX_CONNECTIONS_PER_HOST);

                cm.setMaxConnectionsPerHost(maxConnectionsPerHost);

                // max connections, defaults to constant above
                int maxConnections = getIntegerOption(
                        DefaultCommonsHTTPClientProperties.MAXIMUM_TOTAL_CONNECTIONS_PROPERTY_KEY,
                        DEFAULT_MAX_CONNECTIONS);
                // as per apache-commons problem report #36882 (max connections per host setting does not work)
                // cm.setMaxTotalConnections(maxConnections);
                cm.getParams().setMaxTotalConnections(maxConnections);

                // save the connection manager for future calls
                sConnectionManager = cm;

                sConnectionTimeoutThread = new IdleConnectionTimeoutThread();
                sConnectionTimeoutThread.addConnectionManager(sConnectionManager);

                int sweepInterval = getIntegerOption(KEY_IDLE_SWEEP_INTERVAL,
                        DEFAULT_IDLE_CONNECTION_SWEEP_INTERVAL);
                sConnectionTimeoutThread.setTimeoutInterval(sweepInterval);

                int idleTimeout = getIntegerOption(KEY_IDLE_TIMEOUT, DEFAULT_IDLE_CONNECTION_TIMEOUT);
                sConnectionTimeoutThread.setConnectionTimeout(idleTimeout);
                sConnectionTimeoutThread.start();
            }/*from  ww w . j ava2s  . c o m*/
        }
    }
    connectionManager = sConnectionManager;
    clientProperties = sClientProperties;
}

From source file:org.bench4Q.agent.rbe.HttpClientFactory.java

/**
 * get a HttpClient.//from w ww  .ja va  2s  .  c  om
 * 
 * @return HttpClient
 */
public static HttpClient getInstance() {
    if (m_client == null) {
        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.setMaxConnectionsPerHost(10000);
        connectionManager.setMaxTotalConnections(10000);
        m_client = new HttpClient(connectionManager);

        DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
        retryhandler.setRetryCount(DEFAULT_RETRY_COUNT);
        m_client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
    }
    return m_client;

}