0

How does requestConnection for PoolingNHttpClientConnectionManager work in Apache HttpAsyncClient? Can someone show me a working example?

stones333
  • 8,588
  • 1
  • 25
  • 27

1 Answers1

1

This is how it is being used inside HttpAsyncClient

http://hc.apache.org/httpcomponents-asyncclient-4.1.x/httpasyncclient/xref/org/apache/http/impl/nio/client/AbstractClientExchangeHandler.html

Is there any particular reason you want to use PoolingNHttpClientConnectionManager directly instead of using it through HttpAsyncClient?

ok2c
  • 26,450
  • 5
  • 63
  • 71
  • Yes, it should. Alternatively one can request, say, 5 connections from the pool and immediately release all of them back to the pool. That'll ensure there are 5 warm connections in the pool. – ok2c Aug 14 '15 at 17:07
  • Only by sending a heart-beat message every once in a while. If you can give up proxy support, complex auth schemes and state management you might consider using BasicNIOConnPool. http://hc.apache.org/httpcomponents-core-4.4.x/httpcore-nio/examples/org/apache/http/examples/nio/NHttpClient.java. It offers a simpler API than PoolingNHttpClientConnectionManager. – ok2c Aug 14 '15 at 17:16
  • You need to start the i/o reactor – ok2c Aug 14 '15 at 19:39