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
13
votes
3 answers

Is it possible to set RetryPolicy in spring-retry based on HttpStatus status code?

Is it possible to set RetryPolicy in spring retry (https://github.com/spring-projects/spring-retry) based on error status code? e.g. I want to retry on HttpServerErrorException with HttpStatus.INTERNAL_SERVER_ERROR status code, which is 503.…
Marat Kurbanov
  • 197
  • 1
  • 2
  • 10
12
votes
1 answer

Spring Retry @Recover passing parameters

I couldn't find any info about a possibility of action I need. I am using @Retryable annotation with @Recover handler method. Smth like this: @Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(delay = 10000)) public…
Sviatlana
  • 1,728
  • 6
  • 27
  • 55
10
votes
1 answer

@Retryable is not being triggered

I have tried to boil down the simplest retry scenario possible. The retry is being ignored upon execution. Application.java: @SpringBootApplication @EnableRetry public class Application extends SpringBootServletInitializer { //... This is within a…
Joe Essey
  • 3,457
  • 8
  • 40
  • 69
10
votes
1 answer

Trying to exclude an exception using @Retryable - causes ExhaustedRetryException to be thrown

I'm trying to use @Retryable on a method that calls the REST template. If an error is returned due to a communication error, I want to retry otherwise I want to just thrown an exception on the call. When the ApiException occurs, instead of it being…
Les
  • 487
  • 1
  • 10
  • 22
10
votes
3 answers

Implementing non-blocking retry with backoff with spring-amqp and rabbitmq

I am looking for a good way to implement retries with a backoff policy using spring amqp and Rabbit MQ, but the requirement is that the listener should not be blocked (so it is free to process other messages). I see a similar question asked/answered…
alam86
  • 101
  • 1
  • 5
9
votes
1 answer

Spring @Retryable with stateful Hibernate Object

I am trying to make my Service Method retrying on failure with Springs @Retryable. @Retryable(backoff = @Backoff(delay = 1000), maxAttempts = 3) @Transactional(rollbackFor = Throwable.class) public Something saveSomething(Something something) { …
9
votes
1 answer

How do I access current retry attempt when using @Retryable approach

I am using annotation based approach - @Retryable to do retry in spring boot application. @Retryable(value = {DataAccessException.class, JpaSystemException.class}, maxAttempts = Integer.MAX_VALUE, backoff = @Backoff(delay = 30000)) What I want to…
Saurabh Deshpande
  • 1,153
  • 4
  • 18
  • 35
9
votes
1 answer

Spring retry not working in RestController

I am trying spring retry and I am facing a strange issue. When I use the retry annotation on a method within a Rest Controller, the retry does not work. But if I move that method to a separate service class, it works. The following code does not…
falcon
  • 1,332
  • 20
  • 39
9
votes
2 answers

Spring retry XML equivalent to @EnableRetry

I have to work with a project where I cannot use Java-Config for Spring, but I have to use XML-Config. Now I am looking for an XML-Config equivalent to @EnableRetry from Java-Config. I want this line to work. @Retryable(SQLException.class) public…
Tarken
  • 2,112
  • 2
  • 23
  • 42
8
votes
3 answers

Spring Retry: method annotated with @Recover not being called

I am testing a spring retry, but it seems the recover is not being called. Tried to get it work but it seems exhaustive. I passed to @Recover no argument, Throwable, Exception. Changed retry dependency version, and it seems it is included with aop…
Tadele Azanaw
  • 331
  • 1
  • 2
  • 10
8
votes
3 answers

Annotation way to register listener to spring's @Retryable

How to register a listener in spring-retry using @Retryable() annotation? @Bean public RetryListener myRetryListener() { return new MyRetryListener(); } @Service public class SampleService { private int cnt = 1; …
sanit
  • 1,646
  • 1
  • 18
  • 21
8
votes
1 answer

Spring @Retryable for specific condition

Is it possible to retry based on certain conditions? If I annotate with Retryable, it will retry based on some Exceptions but I want to retry if that exception is caught and the corresponding conditions is…
user123475
  • 1,065
  • 4
  • 17
  • 29
7
votes
1 answer

Understanding Spring Cloud Stream Kafka and Spring Retry

I have a Spring Cloud Stream project using the Kafka binder and I'm trying to understand and eventually customize the RetryTemplate used by Cloud Stream. I'm not finding a lot of documentation on how this works, but what I've read leads me to the…
7
votes
1 answer

Spring Kafka SeekToCurrentErrorHandler Find Out Which Record Has Failed

I have implemented a Kafka consumer with KafkaHandler. My consumer is supposed to consume events, then send a REST request to some other service for each event. I want to retry only if that REST service is down. Otherwise, I can ignore the failed…
Ercument Kisa
  • 168
  • 1
  • 3
  • 12
7
votes
1 answer

How to set Spring Retry template to retry max attempts: infinite

I would like to modify DB connection creation with Spring Retry to try again if DB is down at application startup. I would not like to limit the number of retries. How should I configure the policy to do that. My current code (I know in this state…
user2695543
  • 81
  • 4
  • 22
1
2
3
31 32