10

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 Service class:

public Boolean processItem() {
    Long id = 999L;
    try {
        retrieveItemWithRetry(id);
        return true;
    } catch (NoResultException e) {
        return false;
    }
}

@Retryable(include=NoResultException.class, backoff = @Backoff(delay = 500, maxDelay = 3000), maxAttempts = 5)
private void retrieveItemWithRetry(Long id) {
    retrieveItem(id);
}

private OrderRequest retrieveItem(Long id) {
    throw new NoResultException();
}    
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
Joe Essey
  • 3,457
  • 8
  • 40
  • 69

1 Answers1

19

Internal calls to @Retryable methods (within the same class) are not retryable; see my answer here from yesterday, which explains why.

Further, @Retryable methods must be public.

Community
  • 1
  • 1
Gary Russell
  • 166,535
  • 14
  • 146
  • 179