0

For example, the method was called at 12:00:00 but failed.

I like it to retry at 12:00:01, 12:00:06, 12:00:16, 12:00:46, 12:01:46

How could I make it happen using Spring Retry in Java

I tried the following Custom BackOff Policy but it shows error:

    @Autowired
    private BackOffPolicy customBackOffPolicy;

    @Retryable(value = Exception.class, maxAttempts = 6, backoff = @Backoff(customBackOffPolicy))
    public ResponseResult<List<String>> get() {
        System.out.println("start: " + LocalTime.now());
        ArrayList<String> list = new ArrayList<>(List.of("A", "B", "C"));
        System.out.println("done");
        return ResponseResult.success(list);
    }

error message

Pip
  • 19
  • 3
  • 1
    With what you show here the value is a constant. Please show the actual code and actual error. – M. Deinum Jun 28 '23 at 06:34
  • Update your question to show the actual (relevant) code, then vote to reopen. – Bohemian Jun 28 '23 at 06:40
  • 1
    It's called Exponential Backoff and you can configure it with the [intervalWithCustomExponentialBackoff](https://resilience4j.readme.io/docs/retry#use-a-custom-intervalfunction). – Valerij Dobler Jun 28 '23 at 07:50

0 Answers0