Questions tagged [spring-retry]

Spring Retry provides an abstraction around retrying failed operations, with an emphasis on declarative control of the process and policy-based behaviour that is easy to extend and customize.

The Spring Retry project is refactored from Spring Batch's support for retrying operations as of Spring Batch 2.2.0. It is used in several Spring projects.

See also

469 questions
34
votes
5 answers

Spring Retry with Transactional

Is Spring Retry guaranteed to work with Spring's @Transactional annotation? Specifically, I'm trying to use @Retryable for optimistic locking. It seems like it would be dependent on the ordering of the AOP proxies that were created. For example, if…
Cobra1117
  • 1,150
  • 3
  • 11
  • 26
34
votes
2 answers

Which HTTP errors should never trigger an automatic retry?

I'm trying to make a few microservices more resilient and retrying certain types of HTTP requests would help with that. Retrying timeouts will give clients a terribly slow experience, so I don't intend to retry in this case. Retrying 400s doesn't…
cahen
  • 15,807
  • 13
  • 47
  • 78
34
votes
11 answers

Springboot @retryable not retrying

The following code is not retrying. What am I missing? @EnableRetry @SpringBootApplication public class App implements CommandLineRunner { ......... ......... @Retryable() ResponseEntity authenticate(RestTemplate…
engg
  • 481
  • 4
  • 7
  • 6
27
votes
3 answers

Spring @Retryable - how to log when it is invoked?

I use compile 'org.springframework.retry:spring-retry:1.2.2.RELEASE'with Spring Boot 1.5.9.RELEASE. Configured to retry my method and it works well: @Retryable(value = { IOException.class }, maxAttempts = 5, backoff = @Backoff(delay = 500)) public…
Justinas Jakavonis
  • 8,220
  • 10
  • 69
  • 114
23
votes
3 answers

How to inject config properties in Spring Boot to Spring Retry annotation?

In spring boot application, I define some config properties in yaml file as below. my.app.maxAttempts = 10 my.app.backOffDelay = 500L And an example bean @ConfigurationProperties(prefix = "my.app") public class ConfigProperties { private int…
marcterenzi
  • 319
  • 1
  • 2
  • 10
18
votes
5 answers

How can I make spring @retryable configurable?

I have this piece of code @Retryable(maxAttempts = 3, stateful = true, include = ServiceUnavailableException.class, exclude = URISyntaxException.class, backoff = @Backoff(delay = 1000, multiplier = 2) ) public void testThatService(String…
Sabarish
  • 862
  • 1
  • 14
  • 23
17
votes
4 answers

Retry a method based on result (instead of exception)

I have a method with the following signature: public Optional doSomething() { ... } If I get an empty Optional I'd like to retry this method and only after 3 times return the empty Optional. I've looked and found the Retryable spring…
orirab
  • 2,915
  • 1
  • 24
  • 48
16
votes
7 answers

Feign client and Spring retry

I have a restful service calling an external service using Spring Cloud Feign client @FeignClient(name = "external-service", configuration = FeignClientConfig.class) public interface ServiceClient { @RequestMapping(value = "/test/payments",…
16
votes
4 answers

Spring's @Retryable not working when running JUnit Test

I have this test: @RunWith(MockitoJUnitRunner.class) public class myServiceTest { @InjectMocks myService subject; private myService spy; @Before public void before() { spy = spy(subject); } @Test public void testing() { …
Programmermatt
  • 355
  • 1
  • 4
  • 12
15
votes
3 answers

Spring Retryable annotation ClassNotFoundException

I would like to use @Retryable annotation for restTemplate. I've added: org.springframework.retry spring-retry 1.2.1.RELEASE as well as…
user3529850
  • 1,632
  • 5
  • 32
  • 51
14
votes
2 answers

What are the http codes to automatically retry the request?

I am using the mix Spring-Cloud + feign + spring-retry to help retry requests on the client side (all are Kotlin-based back-ends) My spring-boot conf is like this: myApp: ribbon: OkToRetryOnAllOperations: true retryableStatusCodes: 404,…
Jeremy L
  • 251
  • 1
  • 3
  • 12
13
votes
2 answers

Print retry count with @Retryable

I am using @Retryable on a method like this :- @Retryable( value = SQLException.class, maxAttempts = 5, backoff = @Backoff(delay = 100)) void testMethod(String abc) throws SQLException{ //some method body that could throw sql…
user1354825
  • 1,108
  • 4
  • 21
  • 54
13
votes
1 answer

Spring @EnableRetry throws InternalAutoProxyCreator

I created sample Spring-boot application and it works fine without any error, now I want to practice spring-retry to retry some of the methods. If i don't use @EnableRetry my application starts without any errors but retry is not working. If I use…
Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98
13
votes
1 answer

Exponential backoff with message order guarantee using spring-kafka

I'm trying to implement a Spring Boot-based Kafka consumer that has some very strong message delivery guarentees, even in a case of an error. messages from a partition must be processed in order, if message processing fails, the consumption of the…
13
votes
3 answers

Specifying an exception-specific backoff policy with Spring-Retry

I am using Spring-Retry for some database operations. On a SQLRecoverableException I retry three times (this assumes that whatever is causing the exception is non-transient if it fails three times), on a SQLTransientException I retry indefinitely…
Zim-Zam O'Pootertoot
  • 17,888
  • 4
  • 41
  • 69
1
2 3
31 32