I do not think there is a native method to do so.
I created a wrapper around ClosableHttpClient. This wrapper kept an Atomic 
count of requests and decremented the count on request close or failure. Once 
shutdown was initiated the close method closed the httpclient only if the count 
was zero, or with every request complete checked if shutdown has been 
initiated. You have to be very careful with error handling as its easy to miss 
the decrement and you could never have the count decremented to zero. Also you 
could call close more than once as its idempotent and count go to negative. 
vicky

 

    On Sunday, February 26, 2017 5:47 PM, chuyifan <chuyi...@made-in-china.com> 
wrote:
 

  

Hi:

I am a developer now working on http communication. I want to get some
information about graceful shutdown of httpclient on website. I want to make
sure that the httpclient won't be shut down until all on-going requests have
been processed when I invoked the close method of httpclient. Now I still do
not find anything useful for me. Now time is so pressing, so I want to ask
for help from you. Currently, I use the httpcomponents of version 4.3.1. 

Thank you.



   

Reply via email to