On Mon, 2015-12-07 at 12:12 +0000, Tim Smith wrote: > Hi, > > I'm not too keen on spending hours re-inventing the wheel, so I wanted > to find out what the consensus was on the most efficient way to handle > failover. > > By failover I mean .... > > Attempt to transact with server http://1.example.com > <1.example.com does not respond, or responds with http code <200||>300 > > Attempt to transact with server http://2.example.com > > I am aware there is HttpRequestRetryHandler, but as far as I'm aware > this only applies to requests to the same server ? >
Not quite. HttpClient as of version 4.4 supports so called multi-home hosts, that is hosts with multiple DNS records. HttpClient will attempt to establish connection to a responsive endpoint and only if all of them fail to respond and will propagate the exception up the caller stack to be eventually acted upon by HttpRequestRetryHandler. > > How have others taken care of the same problem ? > If the default fail-over logic is not what you want there is an option of building a custom connection operator and replacing the default one. http://hc.apache.org/httpcomponents-client-4.5.x/httpclient/xref/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.html Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
