set number of retries with HttpAsyncClients
Asked Answered
O

1

6

With the typical HttpAsyncClients example:

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");
    }
}

What is the way to set the number of retries in case there is no response?. I can see 5.

With httpClientBuilder there is the setRetryHandler :

httpClientBuilder.setRetryHandler(new MyRequestRetryHandler(_maxRetryCount));

What is the way with HttpAsyncClients?

Ockham answered 2/3, 2017 at 11:49 Comment(0)
S
11

HttpAsyncClient 4.x does not support automatic request re-execution. This feature is planned for HttpAsyncClient 5.0

Symons answered 2/3, 2017 at 20:7 Comment(2)
Thanks for your answer @olegOckham
It's released already hc.apache.org/httpcomponents-client-5.0.x/index.htmlTaddeusz

© 2022 - 2024 — McMap. All rights reserved.