【问题标题】:set number of retries with HttpAsyncClients使用 HttpAsyncClients 设置重试次数
【发布时间】:2017-07-22 03:17:14
【问题描述】:

以典型的HttpAsyncClients 为例:

public class AsyncClientHttpExchange {

    public static void main(final String[] args) throws Exception {
        CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
        try {
            httpclient.start();
            HttpGet request = new HttpGet("http://httpbin.org/get");
            Future<HttpResponse> future = httpclient.execute(request, null);
            HttpResponse response = future.get();
            System.out.println("Response: " + response.getStatusLine());
            System.out.println("Shutting down");
        } finally {
            httpclient.close();
        }
        System.out.println("Done");
    }
}

在没有响应的情况下设置重试次数的方法是什么?我可以看到 5。

httpClientBuildersetRetryHandler

httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));

HttpAsyncClients是怎么回事?

【问题讨论】:

    标签: java apache-httpclient-4.x apache-httpcomponents apache-httpasyncclient


    【解决方案1】:

    HttpAsyncClient 4.x 不支持自动请求重新执行。此功能计划用于 HttpAsyncClient 5.0

    【讨论】:

    猜你喜欢
    • 2016-01-13
    • 2014-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-07
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多