當前位置: 首頁>>代碼示例>>Java>>正文


Java PoolingHttpClientConnectionManager.setMaxPerRoute方法代碼示例

本文整理匯總了Java中org.apache.http.impl.conn.PoolingHttpClientConnectionManager.setMaxPerRoute方法的典型用法代碼示例。如果您正苦於以下問題:Java PoolingHttpClientConnectionManager.setMaxPerRoute方法的具體用法?Java PoolingHttpClientConnectionManager.setMaxPerRoute怎麽用?Java PoolingHttpClientConnectionManager.setMaxPerRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.conn.PoolingHttpClientConnectionManager的用法示例。


在下文中一共展示了PoolingHttpClientConnectionManager.setMaxPerRoute方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public static void test(){
		PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
		// Increase max total connection to 200  
		cm.setMaxTotal(200);  
		// Increase default max connection per route to 20  
		cm.setDefaultMaxPerRoute(20);  
		// Increase max connections for localhost:80 to 50  
		HttpHost localhost = new HttpHost("http://cc.0071515.com", 80);  
		cm.setMaxPerRoute(new HttpRoute(localhost), 2);  
		  
//		CloseableHttpClient httpClient = HttpClients.custom()  
//		        .setConnectionManager(cm)  
//		        .build();  
		httpClient = HttpClients.custom()  
				.setConnectionManager(cm)  
				.build();  
	}
 
開發者ID:dbiir,項目名稱:ts-benchmark,代碼行數:18,代碼來源:HttpTest.java

示例2: createHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
private CloseableHttpClient createHttpClient(String hostname, int port) {
    ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
    LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
    Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory> create()
            .register("http", plainsf).register("https", sslsf).build();
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
    // 將最大連接數增加
    cm.setMaxTotal(maxTotal);
    // 將每個路由基礎的連接增加
    cm.setDefaultMaxPerRoute(maxPerRoute);
    HttpHost httpHost = new HttpHost(hostname, port);
    // 將目標主機的最大連接數增加
    cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute);
    // 請求重試處理
    return HttpClients.custom().setConnectionManager(cm).setRetryHandler(httpRequestRetryHandler).build();
}
 
開發者ID:adealjason,項目名稱:dtsopensource,代碼行數:17,代碼來源:HttpProtocolParent.java

示例3: PingCheckMonitor

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * @param timeEntity                how often the {@link #monitor()} check needs to be executed
 * @param httpRequest               http request that will be called at regular intervals
 * @param pingTimeoutInMilliseconds timeout in milliseconds for http request execution (ping response)
 * @param pingWindowSize            rolling window frame, which needs to be maintained
 * @param maxFailures               maximum failures allowed in the rolling window frame
 * @param host                      host name (could be localhost)
 * @param port                      port
 */
public PingCheckMonitor(TimeEntity timeEntity,
                        HttpRequest httpRequest,
                        Integer pingTimeoutInMilliseconds,
                        Integer pingWindowSize,
                        Integer maxFailures,
                        String host,
                        Integer port) {
    super(PingCheckMonitor.class.getSimpleName(), timeEntity);
    this.httpRequest = httpRequest;
    this.pingTimeoutInMilliseconds = pingTimeoutInMilliseconds;
    this.host = host;
    this.port = port;
    this.rollingWindowHealthQueue = new RollingWindowHealthQueue(pingWindowSize, maxFailures);
    this.executorService = Executors.newSingleThreadExecutor();
    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxPerRoute(new HttpRoute(new HttpHost(host, port)), 2);
    this.httpClient = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .build();
}
 
開發者ID:flipkart-incubator,項目名稱:ranger,代碼行數:30,代碼來源:PingCheckMonitor.java

示例4: createConnectionManager

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
protected HttpClientConnectionManager createConnectionManager() {
    if (httpClientConfig.isMultiThreaded()) {
        log.debug("Multi-threaded http connection manager created");
        final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        final Integer maxTotal = httpClientConfig.getMaxTotalConnection();
        if (maxTotal != null) {
            cm.setMaxTotal(maxTotal);
        }
        final Integer defaultMaxPerRoute = httpClientConfig.getDefaultMaxTotalConnectionPerRoute();
        if (defaultMaxPerRoute != null) {
            cm.setDefaultMaxPerRoute(defaultMaxPerRoute);
        }
        final Map<HttpRoute, Integer> maxPerRoute = httpClientConfig.getMaxTotalConnectionPerRoute();
        for (final HttpRoute route : maxPerRoute.keySet()) {
            cm.setMaxPerRoute(route, maxPerRoute.get(route));
        }
        return cm;
    }
    log.debug("Default http connection is created without multi threaded option");
    return new BasicHttpClientConnectionManager();
}
 
開發者ID:petalmd,項目名稱:armor,代碼行數:22,代碼來源:HeaderAwareJestClientFactory.java

示例5: ArgusHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * Creates a new Argus HTTP client.
 *
 * @param   endpoint    The URL of the read endpoint including the port number. Must not be null.
 * @param   maxConn     The maximum number of concurrent connections. Must be greater than 0.
 * @param   timeout     The connection timeout in milliseconds. Must be greater than 0.
 * @param   reqTimeout  The connection request timeout in milliseconds. Must be greater than 0.
 * @param   isPreview   Set to true if the collector should skip actually submitting the data.
 *
 * @throws  OrchestraException  If an error occurs.
 */
public ArgusHttpClient(String endpoint, int maxConn, int timeout, int reqTimeout, boolean isPreview) {
    requireArgument((endpoint != null) && (!endpoint.isEmpty()), "Illegal endpoint URL.");
    requireArgument(maxConn >= 2, "At least two connections are required.");
    requireArgument(timeout >= 1, "Timeout must be greater than 0.");
    requireArgument(reqTimeout >= 1, "Request timeout must be greater than 0.");
    try {
        preview = isPreview;
        if (preview) {
            MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
        }

        URL url = new URL(endpoint);
        int port = url.getPort();

        requireArgument(port != -1, "Endpoint must include explicit port.");
        connMgr = new PoolingHttpClientConnectionManager();
        connMgr.setMaxTotal(maxConn);
        connMgr.setDefaultMaxPerRoute(maxConn);

        String routePath = endpoint.substring(0, endpoint.lastIndexOf(':'));
        HttpHost host = new HttpHost(routePath, port);
        RequestConfig defaultRequestConfig = RequestConfig.custom().setConnectionRequestTimeout(reqTimeout).setConnectTimeout(timeout).build();

        connMgr.setMaxPerRoute(new HttpRoute(host), maxConn / 2);
        httpClient = HttpClients.custom().setConnectionManager(connMgr).setDefaultRequestConfig(defaultRequestConfig).build();
        //cookieStore = new BasicCookieStore();
        httpContext = new BasicHttpContext();
        //httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    } catch (MalformedURLException ex) {
        throw new OrchestraException("Error initializing the Argus HTTP Client.", ex);
    }
    LOGGER.info("Argus HTTP Client initialized using " + endpoint);
    this.endpoint = endpoint;
}
 
開發者ID:salesforce,項目名稱:ArgusOrchestra,代碼行數:46,代碼來源:ArgusHttpClient.java

示例6: createHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
private static CloseableHttpClient createHttpClient(int maxTotal, int maxPerRoute, int maxRoute, String hostname, int port) {
    ConnectionSocketFactory plainsf = PlainConnectionSocketFactory
            .getSocketFactory();
    LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory
            .getSocketFactory();
    Registry<ConnectionSocketFactory> registry = RegistryBuilder
            .<ConnectionSocketFactory>create()
            .register("http", plainsf)
            .register("https", sslsf)
            .build();

    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(
            registry);

    // 將最大連接數增加
    cm.setMaxTotal(maxTotal);
    // 將每個路由基礎的連接增加
    cm.setDefaultMaxPerRoute(maxPerRoute);

    // 將目標主機的最大連接數增加
    HttpHost httpHost = new HttpHost(hostname, port);
    cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute);

    // 請求重試處理
    HttpRequestRetryHandler httpRequestRetryHandler = (exception, executionCount, context) -> {
        if (executionCount >= 5) {// 如果已經重試了5次,就放棄
            return false;
        }
        if (exception instanceof NoHttpResponseException) {// 如果服務器丟掉了連接,那麽就重試
            return true;
        }
        if (exception instanceof SSLHandshakeException) {// 不要重試SSL握手異常
            return false;
        }
        if (exception instanceof InterruptedIOException) {// 超時
            return false;
        }
        if (exception instanceof UnknownHostException) {// 目標服務器不可達
            return false;
        }
        if (exception instanceof ConnectTimeoutException) {// 連接被拒絕
            return false;
        }
        if (exception instanceof SSLException) {// SSL握手異常
            return false;
        }

        HttpClientContext clientContext = HttpClientContext.adapt(context);
        HttpRequest request = clientContext.getRequest();
        // 如果請求是冪等的,就再次嘗試
        if (!(request instanceof HttpEntityEnclosingRequest)) {
            return true;
        }
        return false;
    };

    CloseableHttpClient httpClient = HttpClients.custom()
            .setConnectionManager(cm)
            .setRetryHandler(httpRequestRetryHandler)
            .build();

    return httpClient;
}
 
開發者ID:Evan1120,項目名稱:wechat-api-java,代碼行數:64,代碼來源:HttpRequestUtil.java

示例7: createHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public CloseableHttpClient createHttpClient(int maxTotal, int maxPerRoute, int maxRoute,
                                                   String hostname, int port) {
    ConnectionSocketFactory plainsf = PlainConnectionSocketFactory
            .getSocketFactory();
    LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory
            .getSocketFactory();
    Registry<ConnectionSocketFactory> registry = RegistryBuilder
            .<ConnectionSocketFactory> create().register("http", plainsf)
            .register("https", sslsf).build();
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(
            registry);
    // 將最大連接數增加
    cm.setMaxTotal(maxTotal);
    // 將每個路由基礎的連接增加
    cm.setDefaultMaxPerRoute(maxPerRoute);
    HttpHost httpHost = new HttpHost(hostname, port);
    // 將目標主機的最大連接數增加
    cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute);

    // 請求重試處理
    HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() {
        public boolean retryRequest(IOException exception,
                                    int executionCount, HttpContext context) {
            if (executionCount >= _maxRetryTimes) {
                return false;
            }
            if (exception instanceof NoHttpResponseException) {// 如果服務器丟掉了連接,那麽就重試
                return true;
            }
            if (exception instanceof SSLHandshakeException) {// 不要重試SSL握手異常
                return false;
            }
            if (exception instanceof InterruptedIOException) {// 超時
                return false;
            }
            if (exception instanceof UnknownHostException) {// 目標服務器不可達
                return false;
            }
            if (exception instanceof ConnectTimeoutException) {// 連接被拒絕
                return false;
            }
            if (exception instanceof SSLException) {// SSL握手異常
                return false;
            }

            HttpClientContext clientContext = HttpClientContext
                    .adapt(context);
            HttpRequest request = clientContext.getRequest();
            // 如果請求是冪等的,就再次嘗試
            if (!(request instanceof HttpEntityEnclosingRequest)) {
                return true;
            }
            return false;
        }
    };

    CloseableHttpClient httpClient = HttpClients.custom()
            .setConnectionManager(cm)
            .setRetryHandler(httpRequestRetryHandler).build();

    return httpClient;

}
 
開發者ID:jpush,項目名稱:jiguang-java-client-common,代碼行數:64,代碼來源:ApacheHttpClient.java

示例8: createConnectionMgr

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * create custom Http Client connection pool to be used by Http Client
 */
private void createConnectionMgr() {
    connectionMgr = new PoolingHttpClientConnectionManager();
    connectionMgr.setMaxTotal(50);
    connectionMgr.setDefaultMaxPerRoute(20);
    HttpHost localhost = new HttpHost("localhost", 80);
    connectionMgr.setMaxPerRoute(new HttpRoute(localhost), 50);
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:11,代碼來源:GemsHttpRepo.java

示例9: buildHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * Build a HTTP client based on the current properties.
 *
 * @return the built HTTP client
 */
private CloseableHttpClient buildHttpClient() {
    try {

        final ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
        final LayeredConnectionSocketFactory sslsf = this.sslSocketFactory;

        final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("http", plainsf)
                .register("https", sslsf)
                .build();

        final PoolingHttpClientConnectionManager connMgmr = new PoolingHttpClientConnectionManager(registry);
        connMgmr.setMaxTotal(this.maxPooledConnections);
        connMgmr.setDefaultMaxPerRoute(this.maxConnectionsPerRoute);
        connMgmr.setValidateAfterInactivity(DEFAULT_TIMEOUT);

        final HttpHost httpHost = new HttpHost(InetAddress.getLocalHost());
        final HttpRoute httpRoute = new HttpRoute(httpHost);
        connMgmr.setMaxPerRoute(httpRoute, MAX_CONNECTIONS_PER_ROUTE);

        final RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(this.readTimeout)
                .setConnectTimeout(this.connectionTimeout)
                .setConnectionRequestTimeout(this.connectionTimeout)
                .setCircularRedirectsAllowed(this.circularRedirectsAllowed)
                .setRedirectsEnabled(this.redirectsEnabled)
                .setAuthenticationEnabled(this.authenticationEnabled)
                .build();


        final HttpClientBuilder builder = HttpClients.custom()
                .setConnectionManager(connMgmr)
                .setDefaultRequestConfig(requestConfig)
                .setSSLSocketFactory(sslsf)
                .setSSLHostnameVerifier(this.hostnameVerifier)
                .setRedirectStrategy(this.redirectionStrategy)
                .setDefaultCredentialsProvider(this.credentialsProvider)
                .setDefaultCookieStore(this.cookieStore)
                .setConnectionReuseStrategy(this.connectionReuseStrategy)
                .setConnectionBackoffStrategy(this.connectionBackoffStrategy)
                .setServiceUnavailableRetryStrategy(this.serviceUnavailableRetryStrategy)
                .setProxyAuthenticationStrategy(this.proxyAuthenticationStrategy)
                .setDefaultHeaders(this.defaultHeaders)
                .useSystemProperties();

        return builder.build();

    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:58,代碼來源:SimpleHttpClientFactoryBean.java

示例10: buildHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * Build a HTTP client based on the current properties.
 *
 * @return the built HTTP client
 */
private CloseableHttpClient buildHttpClient() {
    try {

        final ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
        final LayeredConnectionSocketFactory sslsf = this.sslSocketFactory;

        final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("http", plainsf)
                .register("https", sslsf)
                .build();

        final PoolingHttpClientConnectionManager connMgmr = new PoolingHttpClientConnectionManager(registry);
        connMgmr.setMaxTotal(this.maxPooledConnections);
        connMgmr.setDefaultMaxPerRoute(this.maxConnectionsPerRoute);

        final HttpHost httpHost = new HttpHost(InetAddress.getLocalHost());
        final HttpRoute httpRoute = new HttpRoute(httpHost);
        connMgmr.setMaxPerRoute(httpRoute, MAX_CONNECTIONS_PER_ROUTE);

        final RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(this.readTimeout)
                .setConnectTimeout(this.connectionTimeout)
                .setConnectionRequestTimeout(this.connectionTimeout)
                .setStaleConnectionCheckEnabled(true)
                .setCircularRedirectsAllowed(this.circularRedirectsAllowed)
                .setRedirectsEnabled(this.redirectsEnabled)
                .setAuthenticationEnabled(this.authenticationEnabled)
                .build();


        final HttpClientBuilder builder = HttpClients.custom()
                .setConnectionManager(connMgmr)
                .setDefaultRequestConfig(requestConfig)
                .setSSLSocketFactory(sslsf)
                .setSSLHostnameVerifier(this.hostnameVerifier)
                .setRedirectStrategy(this.redirectionStrategy)
                .setDefaultCredentialsProvider(this.credentialsProvider)
                .setDefaultCookieStore(this.cookieStore)
                .setConnectionReuseStrategy(this.connectionReuseStrategy)
                .setConnectionBackoffStrategy(this.connectionBackoffStrategy)
                .setServiceUnavailableRetryStrategy(this.serviceUnavailableRetryStrategy)
                .setProxyAuthenticationStrategy(this.proxyAuthenticationStrategy)
                .setDefaultHeaders(this.defaultHeaders)
                .useSystemProperties();

        return builder.build();

    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:58,代碼來源:SimpleHttpClientFactoryBean.java

示例11: buildHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
/**
 * Build a HTTP client based on the current properties.
 *
 * @return the built HTTP client
 */
private CloseableHttpClient buildHttpClient() {
    try {

        final ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
        final LayeredConnectionSocketFactory sslsf = this.sslSocketFactory;

        final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("http", plainsf)
                .register("https", sslsf)
                .build();

        final PoolingHttpClientConnectionManager connMgmr = new PoolingHttpClientConnectionManager(registry);
        connMgmr.setMaxTotal(this.maxPooledConnections);
        connMgmr.setDefaultMaxPerRoute(this.maxConnectionsPerRoute);
        connMgmr.setValidateAfterInactivity(DEFAULT_TIMEOUT);

        final HttpHost httpHost = new HttpHost(InetAddress.getLocalHost());
        final HttpRoute httpRoute = new HttpRoute(httpHost);
        connMgmr.setMaxPerRoute(httpRoute, MAX_CONNECTIONS_PER_ROUTE);

        final RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(this.readTimeout)
                .setConnectTimeout(Long.valueOf(this.connectionTimeout).intValue())
                .setConnectionRequestTimeout(Long.valueOf(this.connectionTimeout).intValue())
                .setCircularRedirectsAllowed(this.circularRedirectsAllowed)
                .setRedirectsEnabled(this.redirectsEnabled)
                .setAuthenticationEnabled(this.authenticationEnabled)
                .build();


        final HttpClientBuilder builder = HttpClients.custom()
                .setConnectionManager(connMgmr)
                .setDefaultRequestConfig(requestConfig)
                .setSSLSocketFactory(sslsf)
                .setSSLHostnameVerifier(this.hostnameVerifier)
                .setRedirectStrategy(this.redirectionStrategy)
                .setDefaultCredentialsProvider(this.credentialsProvider)
                .setDefaultCookieStore(this.cookieStore)
                .setConnectionReuseStrategy(this.connectionReuseStrategy)
                .setConnectionBackoffStrategy(this.connectionBackoffStrategy)
                .setServiceUnavailableRetryStrategy(this.serviceUnavailableRetryStrategy)
                .setProxyAuthenticationStrategy(this.proxyAuthenticationStrategy)
                .setDefaultHeaders(this.defaultHeaders)
                .useSystemProperties();

        return builder.build();

    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw Throwables.propagate(e);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:58,代碼來源:SimpleHttpClientFactoryBean.java

示例12: createHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
private CloseableHttpClient createHttpClient() throws NSPException {
	try {
		initSocketFactory();

		DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
			public InetAddress[] resolve(String host)
					throws UnknownHostException {
				if (host.equalsIgnoreCase("localhost")) {
					return new InetAddress[] { InetAddress
							.getByAddress(new byte[] { 127, 0, 0, 1 }) };
				}

				return super.resolve(host);
			}
		};
		PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(
				this.socketFactoryRegistry, dnsResolver);

		SocketConfig socketConfig = SocketConfig.custom()
				.setTcpNoDelay(true).setSoKeepAlive(true).setSoLinger(0)
				.setSoReuseAddress(true).build();

		connManager.setDefaultSocketConfig(socketConfig);

		ConnectionConfig connectionConfig = ConnectionConfig.custom()
				.setCharset(Consts.UTF_8).build();
		connManager.setDefaultConnectionConfig(connectionConfig);
		connManager.setConnectionConfig(new HttpHost("localhost", 80),
				ConnectionConfig.DEFAULT);

		connManager.setMaxTotal(this.mMaxConnections);

		if ((this.mMaxConnections <= this.mConnectionsPerRoute)
				&& (this.mMaxConnections > 0)) {
			this.mConnectionsPerRoute = this.mMaxConnections;
		}

		connManager.setDefaultMaxPerRoute(this.mConnectionsPerRoute);

		connManager.setMaxPerRoute(new HttpRoute(new HttpHost("localhost",
				80)), 100);

		CloseableHttpClient httpclient = HttpClients
				.custom()
				.setConnectionManager(connManager)
				.setDefaultRequestConfig(
						RequestConfig.copy(defaultRequestConfig).build())
				.build();

		return ((CloseableHttpClient) new WeakReference(httpclient).get());
	} catch (Exception e) {
		throw new NSPException(2, "Service unavailable.", e);
	}
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:55,代碼來源:HttpConnectionAdaptor.java


注:本文中的org.apache.http.impl.conn.PoolingHttpClientConnectionManager.setMaxPerRoute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。