最简单的重试机制




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;
}
}
posted @ 2016-10-28 09:19  托马斯布莱克  阅读(740)  评论(0编辑  收藏  举报