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

How to write unit test for Spring retry logic?

I have a service class as below, for which I am trying to test retry logic public class RemoteService { private RestTemplate restTemplate; @Inject public RemoteService(RestTemplate restTemplate) { this.restTemplate =…
Nichole
  • 189
  • 2
  • 7
3
votes
1 answer

How can I cancel a retry?

Using Spring Retry, I have a retry going on in 1 thread. In some circumstances, I would like to be able to cancel the retry before it has reached the configured number of retries. What is the best way to achieve this with this library? I have tried…
Rupert Madden-Abbott
  • 12,899
  • 14
  • 59
  • 74
3
votes
2 answers

Spring webclient - increase timeout duration after each retry

I am looking for a way to increase the duration of the timeout after successive retries on webclient calls. For example, I want the first request to timeout after 50ms, the first retry will then timeout after 500ms, and a second and final retry to…
3
votes
1 answer

Adding new header when retrying with Spring WebClient

webclientbuilder.baseUrl(url) .defaultHeaders(headers -> headers.addAll(requestHeader)) .build() .post() .uri("/uri") .bodyValue(data) .exchange() …
3
votes
1 answer

@ConditionalOnMissingBean vs @ConditionalOnSingleCandidate

We´re working on multi-module project where each module is a cutom spring boot starter that holds several retryable tasks. (Using spring-retry) In order to ensure that retry annotations are activated only once cross starters, a configuration bean is…
Katy
  • 1,023
  • 7
  • 19
3
votes
1 answer

@Retryable method not working that also is @Scheduled and @EnableSchedulerLock

I want to create a cron job which is retry-able and only 1 instance should execute it when we deploy multiple instances of the application. I have also referred @Recover annotated method is not discovered for a @Retryable method that also is…
letsDoThis
  • 71
  • 1
  • 7
3
votes
1 answer

Can spring cloud stream kafka binder allow/deny retry for specific exceptions?

Is it possible to add a property to the application.yml to include/exclude certain exceptions from being retried in the policy defined below? I swear that I read somewhere that there is a property for this, but now I cannot find it again for the…
3
votes
1 answer

How to make configurable Retryable maxAttempts and backoff from application.properties file in spring boot

Below parameter, trying to make configurable @Async("threadPoolTaskExecutor") @Retryable(value = MessagingException.class, maxAttempts = 2, backoff = @Backoff(delay = 5000)) I did the following changes in application.properties…
Praveen D
  • 2,337
  • 2
  • 31
  • 43
3
votes
2 answers

Retry not working with Spring Batch with Java Config

I have Spring batch job with following config: @Bean public Job myJob(Step step1, Step step2, Step step3) { return jobs.get("myJob").start(step1).next(step2).next(step3).build(); } @Bean public Step step1(ItemReader myReader, …
adesai
  • 370
  • 3
  • 22
3
votes
2 answers

Spring Retry on JPA repository

I am new to spring, as part of my project implementation, I am supposed to add a spring retry on a service method that invokes JPA repository. Code looks something like below @Retryable(value = {Exception.class},maxAttempts = 1,backoff =…
Suman
  • 143
  • 1
  • 11
3
votes
1 answer

@Retryable is not working when calling from a method

Below is my application class. The flow is like the DEToken class from here and from DEToken I call RestConnection where I have the @retryable method. @SpringBootApplication @EnableRetry public class SpringBootTrfficApplication implements…
Shilpi
  • 109
  • 3
  • 12
3
votes
2 answers

How to create custom retry logic for Spring Datasource?

I'm connecting to an Azure SQL database and my next task is to create custom retry logic when a connection has failed. I would like the retry logic to run both on startup (if needed) as well as any time there's a connection failure while the app is…
3
votes
1 answer

Spring-retry - @Circuitbreaker is not retrying

I'm running into an issue where @CircuitBreaker is not retrying. I have a service class (ex. Class UserService and method name getUser), this method calls another Spring bean (ex. AppClient and execute) which in turn makes call to remote…
Dilip P
  • 33
  • 1
  • 5
3
votes
1 answer

Spring-Retry with Circuit breaker

I am trying to leverage both the retry and circuit breaker mechanism of spring-retry. I tried to use both annotations(@Retryable and @CircuitBreaker) in a particular function(like below), but Circuit Breaker was not working. @Service public class…
Tanay Mathur
  • 379
  • 2
  • 5
  • 16
3
votes
1 answer

Disable Spring Batch single-item processing in skip situation

I have a job that processes items in chunks (of 1000). The items are marshalled into a single JSON payload and posted to a remote service as a batch (all 1000 in one HTTP POST). Sometime the remote service bogs down and the connection times out. I…
Ken DeLong
  • 929
  • 2
  • 8
  • 27