Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpClient: What is the difference between ServiceUnavailableRetryStrategy and HttpRequestRetryHandler?

I was hoping to deal with this situation where i want it to do retry after a delay, but it seems that the delay that i set in ServiceUnavailableRetryStrategy didnt take place :

19:42:29.046 [scheduler-15] INFO o.a.http.impl.execchain.RetryExec - I/O exception (org.apache.http.NoHttpResponseException ) caught when processing request to {}->http://testing.com:80: The target server failed to respond 19:42:29.049 [scheduler-15] INFO o.a.http.impl.execchain.RetryExec - Retrying request to {}->http://testing.com:80

I have both of ServiceUnavailableRetryStrategy and HttpRequestRetryHandler set. And from both, it seems that only ServiceUnavailableRetryStrategy has a delay option, where i dont see any delay options for httpRequestRetryHandler.

So in the case of the NoHttpResponseException above, which one is actually used ? And what's the difference between those two ?

like image 675
Albert Gan Avatar asked Jun 14 '14 13:06

Albert Gan


People also ask

What is the difference between HttpClient and CloseableHttpClient?

CloseableHttpClient is the base class of the httpclient library, the one all implementations use. Other subclasses are for the most part deprecated. The HttpClient is an interface for this class and other classes. You should then use the CloseableHttpClient in your code, and create it using the HttpClientBuilder .

What is setConnectionTimeToLive?

public final HttpClientBuilder setConnectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit) Sets maximum time to live for persistent connections. Please note this value can be overridden by the setConnectionManager(org. apache.

What is HttpClientBuilder in Java?

HttpClientBuilder. useSystemProperties() Use system properties when creating and configuring default implementations. Methods inherited from class java.lang.Object. clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait.

What is Apache HttpClient?

The Apache HttpClient library allows to handling HTTP requests. To use this library add a dependency to your Maven or Gradle build file. You find the latest version here: https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient. You retrieve and send data via the HttpClient class.

What is HTTP and httpclient?

HttpClient provides some well-awaited features. It exists as a separate module called @angular/common/http to ensure retro compatibility with the traditional Http client, living in the module @angular/http. In this article I will show you the differences between Http and HttpClient.

What is the difference between httpwebrequest and webclient?

WebClient is just a wrapper around HttpWebRequest, so it uses HttpWebRequest internally. The WebClient bit slow compared to HttpWebRequest.But is very much less code. we can use WebClient for simple ways to connect and work with HTTP services. Add code for downloading string data from Rest API using WebClient. We can pass optional headers.

What is the difference between HTTP and httpclient in Angular 5?

Angular HTTP vs. HttpClient -. The HttpClient is used to perform HTTP requests and it imported form @angular/common/http. The HttpClient is more modern and easy to use the alternative of HTTP. HttpClient is an improved replacement for Http. They expect to deprecate Http in Angular 5 and remove it in a later version.

What is httpcomponentsclienthttprequestfactory?

HttpComponentsClientHttpRequestFactory is ClientHttpRequestFactory implementation that uses Apache HttpComponents HttpClient to create requests. We have used @Scheduled annotation in httpClient configuration. To support this, we have to add support of scheduled execution of thread.


1 Answers

  • HttpRequestRetryHandler represents a strategy determining whether or not the request is safe to retry in case of an I/O error (no HTTP response has been received from the server).

  • ServiceUnavailableRetryStrategy represents a strategy determining whether or not the request should be retried after a while in case of the service being temporarily unavailable (response status 503).

In 5.0 the two interfaces are likely to get replaced by a single strategy interface.

like image 74
ok2c Avatar answered Oct 24 '22 04:10

ok2c