apache 的HttpClient 的默认重试机制
maven
异常重试log
RetryExec
org/apache/http/impl/execchain/RetryExec.java
DefaultHttpRequestRetryHandler
org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
<dependency>
<groupId>org.apache.httpcomponents </groupId>
兵马俑<artifactId>httpclient </artifactId>
<version>4.5.2</version>
</dependency>
2017-01-31 19:31:39.057 INFO 3873 --- [askScheduler-13] o.apache.hain.RetryExec : I/O exception (org.apache.http.NoHttpRespon Exception) caught when processing request to {}->192.168.99.100:8080: The target rver failed to respond
2017-01-31 19:31:39.058 INFO 3873 --- [askScheduler-13] o.apache.hain.RetryExec : Retrying request to {}->192.168.99.100:8
080
心旷神怡什么意思
/**
* Request executor in the request execution chain that is responsible
我的年度关键词* for making a decision whether a request failed due to an I/O error
* should be re-executed.
* <p>
* Further responsibilities such as communication with the opposite
* endpoint is delegated to the next executor in the request execution
* chain.
* </p>
*
* @since 4.3
*/
@Immutable
public class RetryExec implements ClientExecChain {
private final Log log = Log(getClass());
private final ClientExecChain requestExecutor;挑染头发图片
private final HttpRequestRetryHandler retryHandler;
public RetryExec(
final ClientExecChain requestExecutor,
final HttpRequestRetryHandler retryHandler) {
默认重试3次,三次都失败则抛出NoHttpResponException或其他异常
doc /**脆性x综合症
* The default {@link HttpRequestRetryHandler} ud by request executors.
*
* @since 4.0
*/
保马@Immutable与其造句
public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { public static final DefaultHttpRequestRetryHandler INSTANCE = new DefaultHttpRequestRetryHandler(); /** the number of times a method will be retried */
private final int retryCount;
/** Whether or not methods that have successfully nt their request will be retried */ private final boolean requestSentRetryEnabled;
一处相思两处闲愁
private final Set<Class<? extends IOException>> nonRetriableClass;
/**
* Create the request retry handler using the specified IOException class
*
* @param retryCount how many times to retry; 0 means no retries
* @param requestSentRetryEnabled true if it's OK to retry requests that have been nt