Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Add automatic retry to fluent RestTemplate calls #13

Closed
achudzik opened this issue Sep 5, 2014 · 8 comments
Closed

Add automatic retry to fluent RestTemplate calls #13

achudzik opened this issue Sep 5, 2014 · 8 comments

Comments

@achudzik
Copy link
Contributor

achudzik commented Sep 5, 2014

Hystrix doesn't handle automatic retry by design (see this tweet). Maybe Spring Retry can be used instead? All suggestions are welcomed.

@marcingrzejszczak
Copy link
Contributor

Looks great! We may add a new retry method to the fluent api that could delegate to RetryOperations. We would have to check if aspects would new to be changed accordingly to place correlation ids.

@szpak
Copy link
Collaborator

szpak commented Sep 6, 2014

Btw, I have never used Spring Retry in my project, but AFAIK the waiting process in SR is blocking (see ThreadWaitSleeper which seems to be used in different BackOffPolicy implementations). That would mean that given thread is blocked for long seconds or minutes which does not scale well.
Maybe there is a way to make it non blocking in Spring Retry (or you don't treat it as a problem), but there is a nice looking async-retry library written by @nurkiewicz which seems to address that issue.
The problem could be that async-retry officially only supports Java 8 while micro-infra-spring seems to be compatible also with 1.7.

@nurkiewicz
Copy link
Contributor

the waiting process in SR is blocking (see ThreadWaitSleeper which seems to be used in different BackOffPolicy implementations)

That's right, at the time I wrote async-retry RetryTemplate couldn't be tweaked to use asynchronous retrying. That was the reason to start the project in the first place.

Maybe there is a way to make it non blocking in Spring Retry

Nope. See above.

library [...] which seems to address that issue

It depends on whether this is an issue for you or not. If your fluent RestTemplate is blocking by design, I see no problem here. But if it returns Future/CompletableFuture/rx.Observable (it should!), then wasting thread for mostly sleeping is a poor idea. In that case async-retry can be seamlessly integrated.

async-retry officially only supports Java 8

Yes, I was maintaining java7 branch for quite a while (using ListenableFuture from Guava rather then new CompletableFuture in JDK8) and it's only few commits behind master requiring Java 8. I simply didn't have time to support boring Java 7 branch ;-).

@marcingrzejszczak
Copy link
Contributor

@nurkiewicz so maybe we could count on you on making this branch up to date? :) and maybe also a PR for this one? :D

@nurkiewicz
Copy link
Contributor

Sorry, missed last comment. It should be fairly straightforward, Java 7 branch lacks one bug fix and is not in Maven Central. Please track progress in nurkiewicz/async-retry#4.

@nurkiewicz
Copy link
Contributor

async-retry was just backported to Java 7. If I manage to find some time, I can look at this issue, but probably next in this week. Leave a comment if you start working on this ticket first.

Just keep in mind that Hystrix 1.4 RC1 brings very useful HystrixObservableCommand (Netflix/Hystrix#209) that would most likely fit quite well with asynchronous retrying. Give me some time to investigate it.

@marcingrzejszczak
Copy link
Contributor

Ok let's do as you say - if any of us wants to pick it we will send a msg here about it. Otherwise it's yours. If you need any support just ping any of us.

@nurkiewicz nurkiewicz self-assigned this Nov 21, 2014
@nurkiewicz nurkiewicz added this to the 0.7.2 milestone Nov 27, 2014
nurkiewicz added a commit that referenced this issue Dec 2, 2014
nurkiewicz added a commit that referenced this issue Dec 2, 2014
nurkiewicz added a commit that referenced this issue Dec 2, 2014
@gotpist1
Copy link

gotpist1 commented Jun 7, 2017

@nurkiewicz Is it possible to use AsyncRetry with Springs AsyncRestTemplate? I messed around abit with it yesterday, but didn't get it to work. Stumbled upon this thread and thought i would ask the expert :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants