分布式事务

注解: 
@GlobalTransactional
 
手写:
GlobalTransaction tx = GlobalTransactionContext.getCurrentOrCreate();

        try {
            tx.begin();
            tx.commit();//不能提交
        }catch (Exception e){
            log.error("下单失败");
            try{
                tx.rollback();
            } catch (TransactionException ex) {
                log.info("回滚失败");
            }

        }

  

posted @ 2023-08-14 17:21  每月工资一万八  阅读(38)  评论(0)    收藏  举报