I want to have a retry mechanism where if a task is failed and it should be retried after an interval without blocking or sleeping any thread.
For example, lets assume I have maxRetryAttempt as 3 and interval between retry is 3 seconds. I have list of task 1,2, 3,..10 Worker thread picks the task 1. If Task 1 is failed now and I want to retry it but next retry attempt is after 3 seconds. Here I dont want to put my thread into sleep. Instead of that, I want to put the task into some queue and worker thread should pick the task exactly after 3 seconds to retry that task.
I have checked few existing libraries like spring-retry. Those are libraries taking a job and making a thread to sleep before another attempt. So that all tasks are taking 9 seconds before give up (assume worst case, all tasks are failing due to some problem). In this case, 10 different worker threads are getting populated and all are waiting.
Is there any library or design pattern or idea which is matching my expectation?