Retry with 30 minutes delay

467 Views Asked by At

I need to call a external rest service, if it fails on first attempt then I have to call again after 30 minutes. Max 3 time I can call like this. I know spring has RetryTemplate for the retry. But I feel, for my cases its not fit. I have to call like this for more than 1000 records.

Any idea How can I achieve this in Spring.

1

There are 1 best solutions below

0
On

Use a TaskScheduler.

scheduler.schedule(() -> { ... }, 
    new Date(System.currentTimeMillis() + (30 * 60_000));

Keep track of how many times and if not exhausted, re-schedule.