PoolingClientConnectionManager

PoolingClientConnectionManager

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

问题描述

,并引入了一种新方法。

ThreadSafeClientConnManager is deprecated and a new method is introduced PoolingClientConnectionManager.

PoolingClientConnectionManager的文档说

The documentation of PoolingClientConnectionManager says

我的问题

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

推荐答案

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

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

使用如下:

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;
}

来源:

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

09-16 04:41