最简单的重试机制




try {
return dao.updateBanana(d);
}catch(DeadlockLoserDataAccessException e) {
logger.error("An unexpected error occurred for userId {} , exception : {}.",userId,e.getMessage());
try {
//增加出错重试,在产生死锁的异常中,重试可能有很大几率成功
return dao.updateBanana(d);
}catch (DeadlockLoserDataAccessException ex) {
logger.error("An unexpected error occurred for userId {} again, exception : {}.",userId,e.getMessage());
return 0;
}
}
原文地址:https://www.cnblogs.com/xmanblue/p/6006504.html