question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Retry on Timeout?

See original GitHub issue

Is it possible to retry a call when a timeout occurs? At the moment I use TimeLimiter, CircuitBreaker, Retry and Bulkhead like this:

`ExecutorService executorService = Executors.newSingleThreadExecutor(); Supplier<Future<T>> futureSupplier = () -> executorService.submit(pCallable);

Callable<T> callable = TimeLimiter.decorateFutureSupplier(timeLimiter, futureSupplier); callable = CircuitBreaker.decorateCallable(circuitBreaker, callable); callable = Retry.decorateCallable(retry, callable); callable = Bulkhead.decorateCallable(bulkhead, callable);

return Try.ofCallable(callable).get();`

When a timeout occurs the execution stops immediately and there is no retry. Or is the retry mechanism only for exceptions within the timeout duration?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
RobWincommented, Feb 1, 2019

But there are also methods to decorate an CompletionStage (CompletableFuture)

Supplier<CompletionStage<String>> completionStageSupplier =
                () -> CompletableFuture.supplyAsync(helloWorldService::returnHelloWorld);

Supplier<CompletionStage<String>> decoratedCompletionStageSupplier =
    CircuitBreaker.decorateCompletionStage(circuitBreaker, completionStageSupplier)
     .get()
     .thenApply(value -> value + " world");;
1reaction
RobWincommented, Apr 1, 2019

Btw. in the meantime you can use

Retry retry = Retry.ofDefaults("test");
Supplier<CompletableFuture<String>> futureSupplier = () -> CompletableFuture.supplyAsync(() -> "Hello");
Callable<String> callable = TimeLimiter.decorateFutureSupplier(TimeLimiter.of(Duration.ofMillis(500)), futureSupplier);
String result = Retry.decorateCheckedSupplier(retry, callable::call).apply();

I will also add a retry.executeCheckedSupplier method to reduce the overhead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure datafactory retry and timeout - Microsoft Q&A
Timeout property mentions the duration of time the pipeline waits for the activities to finish. Once the timeout duration is reached, pipeline ...
Read more >
How to retry blocking IO Action when timeout? - Stack Overflow
In my case: I have a number of retries and let's say I want to perform an IO action with a timeout. How...
Read more >
Question: Timeout and Retry settings? - Boomi Community
Hi,. Can I set up a retry count , retry intreval and a timeout for my Boomi SOAP Client connector?
Read more >
Couchbase.Core.Retry.BestEffortRetryStrategy Timeout Error
Hi, We seem to be getting intermittent timeout errors when using SDK 3.2.8 for KV Gets (ICouchbaseCollection.GetAsync), but aren't sure if ...
Read more >
Timeouts, retries and backoff with jitter - Amazon AWS
To avoid this problem, we implement our clients to use backoff. This increases the time between subsequent retries, which keeps the load on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found