hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vicky Singh <vicky_sim...@yahoo.com.INVALID>
Subject Re: How to gracefully shutdown httpclient
Date Mon, 27 Feb 2017 15:26:15 GMT
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. 


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



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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message