Asynchronous retry pattern

When you have a piece of code that often fails and must be retried, this Java 7/8 library provides rich and unobtrusive API with fast and scalable solution to this problem:
 
 
 
 
 
 
 
 
 

ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();RetryExecutor executor = new AsyncRetryExecutor(scheduler).    retryOn(SocketException.class).    withExponentialBackoff(500, 2).     //500ms times 2 after each retry    withMaxDelay(10_000).               //10 seconds    withUniformJitter().                //add between +/- 100 ms randomly    withMaxRetries(20);

Source : http://www.javacodegeeks.com/2013/08/asynchronous-retry-pattern.html

Back to Top