3
ENV:
- 的Java 6
- 的Apache的HttpClient 4.2.3
问题详细信息:
继HttpClient的手册,当我使用DefaultHttpClient没有配置任何连接管理器。我们需要让连接管理器关闭。在httpclient 4.x.x中,当我们将PoolingClientConnectionManager配置为httpclient时,我们是否需要手动释放连接?
但是,当我在很多服务器上有很多请求时,我会将PoolingClientConnectionManager配置为连接管理器。在这种情况下,我在Apache网站上找不到任何参考 - 我应该做些什么来释放特定httpclient请求的连接吗?或者httpclient会在框架级自动执行它?
我在___DefaultRequestDirector___中看到httpclient的源代码,看来它会处理连接关闭的东西。我不确定它是因为我在其官方文件中找不到肯定的参考。 httpclient项目变化太快,所以文档比源代码慢。你能找到一些肯定/官方的参考吗? – 2013-03-14 09:22:39
请参阅http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d5e139和http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org /apache/http/examples/client/ClientConnectionRelease.java。对于HC 4.3,人们也可以使用Java 7'尝试使用资源'来确保连接释放和资源释放http://hc.apache.org/httpcomponents-client-dev/httpclient/examples/org/apache/http/examples/client /ClientConnectionRelease.java – oleg 2013-03-14 12:25:10
我正在使用4.2.3,该指南(4.3-dev)似乎没有解决我的问题。 – 2013-03-19 10:56:04