老师好,您在视频里说“一旦发送消息失败,就没有机会回滚库存”,这句话我没能理解,下面的if不就是用来回滚的吗?
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
// 异步减库存 2019.06.05
boolean mqResult = itemService.asyncDecreaseStock(itemId, amount);
//if (!mqResult) {
// itemService.increaseStock(itemId, amount);
// throw new BusinessException(BusinessErrEnum.MQ_SEND_FAILED);
//}
}
});