2014-03-05 47 views

回答

1

這是值得考慮的Spring Retry功能。

的API被構造爲不可知的要重試什麼和關注的是重試的政策,回退,如果你使用的是Java 7/8限重等

另一種可能的數是AsyncRetryExecutor。例如

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); 
相關問題