“每条路线”的含义是什么?在PoolingClientConnectionManager中? [英] What is the meaning of "per route basis" in PoolingClientConnectionManager?

查看:136
本文介绍了“每条路线”的含义是什么?在PoolingClientConnectionManager中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不推荐使用ThreadSafeClientConnManager ,并引入了一种新方法 PoolingClientConnectionManager

ThreadSafeClientConnManager is deprecated and a new method is introduced PoolingClientConnectionManager.

PoolingClientConnectionManager的文档说

The documentation of PoolingClientConnectionManager says


管理一组客户端连接,并能够为来自多个执行线程的连接
请求提供服务。连接以每条路线
为基础汇总。

Manages a pool of client connections and is able to service connection requests from multiple execution threads. Connections are pooled on a per route basis.

我的问题

这里每条路线的含义是什么?

推荐答案

它指的是HttpRoute。 HttpRoute用于描述在同一Web服务器上运行的多个应用程序。

It refers to the HttpRoute. The HttpRoute is to delineate multiple applications running on the same web server.

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/ conn / routing / HttpRoute.html

使用如下:

ClientConnectionRequest connRequest = connMrg.requestConnection(
        new HttpRoute(new HttpHost("localhost", 80)), null);
ManagedClientConnection conn = connRequest.getConnection(10, TimeUnit.SECONDS);
try {
    BasicHttpRequest request = new BasicHttpRequest("GET", "/");
    conn.sendRequestHeader(request);
    HttpResponse response = conn.receiveResponseHeader();
    conn.receiveResponseEntity(response);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        BasicManagedEntity managedEntity = new BasicManagedEntity(entity, conn, true);
        // Replace entity
        response.setEntity(managedEntity);
    }
    // Do something useful with the response
    // The connection will be released automatically 
    // as soon as the response content has been consumed
} catch (IOException ex) {
    // Abort connection upon an I/O error.
    conn.abortConnection();
    throw ex;
}

来源: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

这篇关于“每条路线”的含义是什么?在PoolingClientConnectionManager中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆