/** * 私有的构造方法 */ private HttpProtocolHandler() { // 创建一个线程安全的HTTP连接池 connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn); IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); ict.addConnectionManager(connectionManager); ict.setConnectionTimeout(defaultIdleConnTimeout); ict.start(); }
/** * 私有的构造方法 */ private HttpProtocolHandler() { // 创建一个线程安全的HTTP连接池 connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost( defaultMaxConnPerHost); connectionManager.getParams().setMaxTotalConnections( defaultMaxTotalConn); IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); ict.addConnectionManager(connectionManager); ict.setConnectionTimeout(defaultIdleConnTimeout); ict.start(); }
/** * 私有的构造方法 */ private AliPayHttpProtocolHandler() { // 创建一个线程安全的HTTP连接池 connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn); IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); ict.addConnectionManager(connectionManager); ict.setConnectionTimeout(defaultIdleConnTimeout); ict.start(); }
/** * 私有的构造方法. */ private HttpProtocolHandler() { // 创建一个线程安全的HTTP连接池 connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn); IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); ict.addConnectionManager(connectionManager); ict.setConnectionTimeout(defaultIdleConnTimeout); ict.start(); }
private void initHttpConnectionManager() throws Exception { httpConnectionManager = new MultiThreadedHttpConnectionManager(); int maxConnectionsPerHost = bpelServerConfiguration.getMaxConnectionsPerHost(); int maxTotalConnections = bpelServerConfiguration.getMaxTotalConnections(); if (log.isDebugEnabled()) { log.debug(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS + "=" + maxConnectionsPerHost); log.debug(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS + "=" + maxTotalConnections); } if (maxConnectionsPerHost < 1 || maxTotalConnections < 1) { String errmsg = HttpConnectionManagerParams.MAX_HOST_CONNECTIONS + " and " + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS + " must be positive integers!"; log.error(errmsg); throw new Exception(errmsg); } httpConnectionManager.getParams().setDefaultMaxConnectionsPerHost(maxConnectionsPerHost); httpConnectionManager.getParams().setMaxTotalConnections(maxTotalConnections); // TODO: Modify this and move configuration to bps.xml // Register the connection manager to a idle check thread idleConnectionTimeoutThread = new IdleConnectionTimeoutThread(); idleConnectionTimeoutThread.setName("Http_Idle_Connection_Timeout_Thread"); long idleConnectionTimeout = Long.parseLong( odeConfigurationProperties .getProperty("http.idle.connection.timeout", "30000")); long idleConnectionCheckInterval = Long.parseLong( odeConfigurationProperties .getProperty("http.idle.connection.check.interval", "30000")); if (log.isDebugEnabled()) { log.debug("http.idle.connection.timeout=" + idleConnectionTimeout); log.debug("http.idle.connection.check.interval=" + idleConnectionCheckInterval); } idleConnectionTimeoutThread.setConnectionTimeout(idleConnectionTimeout); idleConnectionTimeoutThread.setTimeoutInterval(idleConnectionCheckInterval); idleConnectionTimeoutThread.addConnectionManager(httpConnectionManager); idleConnectionTimeoutThread.start(); }