On Sat, 2010-04-17 at 09:03 +0530, Ruwan Linton wrote:
> Hi Oleg,
> 
> I was able to get hold of the server side connection pool with using a list
> and recording them using the above mentioned methods.
> 
> Now I was trying to check the condition, whether a connection is being used
> or not at a given point in time. Meaning that whether this particular
> connection has a message in-flight at the given instance, could you help me
> on figuring out that condition as well?
> 
> Checking both, getHttpRequest and getHttpResponse to be null will work, if
> my understanding of the code is correct, but is there a better way to check
> the above condition?
> 

Hi Ruwan

You have got to be very careful here. HTTP connection objects are not
thread safe! One can easily run into a race condition when interacting
with connection objects from any other but an I/O dispatch thread.

So, Here is the recommended way of going about this problem. You should
signal the intention to terminate the connection by setting a special
attribute in the session context or changing the state of the shared
connection state object and let the connection shut down itself, when it
is done processing the actual message. If the persistent connection is
idle, you may need to active it by using the IOControl interface.

http://hc.apache.org/httpcomponents-core-4.0.1/tutorial/html/nio.html#d0e1301

Hope this helps

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to