Smart Retry 主要是用来进行方法重试的。和Guava Retry、Spring Retry相比,Smart Retry最大的特点是异步重试,支持持久化,系统重启之后可以继续重试。
<dependency> <groupId>com.github.hadoop002.smartretry</groupId> <artifactId>retry-spring4</artifactId> <version>1.3.3</version> </dependency>
@RetryFunction(identity = "order.payment") public void payOrderAndUpdateStatus(Order order) { boolean success = paymentBusiness.doPayment(order); if (success) { orderBusiness.updateOrderPayStatus(order); } else { orderBusiness.updateOrderPayFail(order); } }