hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Conley <mike.con...@unizin.org>
Subject Responding adaptively to 503 errors (including respecting the Retry-After header)
Date Wed, 14 Oct 2015 20:49:11 GMT
Hi.

I’m writing an OAI harvester (it’s an obscure protocol you’ve probably never heard of
for the exchange of metadata with content repositories). The implementation guidelines mention
503 handling: http://www.openarchives.org/OAI/2.0/guidelines-harvester.htm#FlowControl <http://www.openarchives.org/OAI/2.0/guidelines-harvester.htm#FlowControl>.
In particular, the suggestion is to respect the Retry-After header if present.

When last I did this, I had to implement it myself, but I see that HttpClient 4 has 503 handling
built in.

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/ServiceUnavailableRetryStrategy.html
<http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/ServiceUnavailableRetryStrategy.html>

But I’m not sure how to use this if the retry interval should vary per-response. getRetryInterval
takes no arguments, and in particular has no access to the HttpResponse, so I’m not sure
how I could go about using this. I had considered storing something when the call to retryRequest
is made, but I’m not sure this is safe to do (it seems likely that it is not, since the
strategy is almost certainly shared among multiple threads). It also seems kind of kludgy
to me. Is there a way to do this cleanly? If not, is there a thread safe way to keep this
state around between calls to the two methods?


Mime
View raw message