txlcn-tc/src/main/java/com/codingapi/txlcn/tc/core/DTXServiceExecutor.java
public Object transactionRunning(TxTransactionInfo info) throws Throwable {

        // 1. 获取事务类型
        String transactionType = info.getTransactionType();

        // 2. 获取事务传播状态
        DTXPropagationState propagationState = propagationResolver.resolvePropagationState(info);

        // 2.1 如果不参与分布式事务立即终止
        if (propagationState.isIgnored()) {
            return info.getBusinessCallback().call();
        }

        // 3. 获取本地分布式事务控制器
        DTXLocalControl dtxLocalControl = txLcnBeanHelper.loadDTXLocalControl(transactionType, propagationState);

        // 4. 织入事务操作
        try {
            // 4.1 记录事务类型到事务上下文
            Set<String> transactionTypeSet = globalContext.txContext(info.getGroupId()).getTransactionTypes();
            transactionTypeSet.add(transactionType);

            dtxLocalControl.preBusinessCode(info);

            // 4.2 业务执行前
            txLogger.txTrace(
                    info.getGroupId(), info.getUnitId(), "pre business code, unit type: {}", transactionType);

            // 4.3 执行业务
            Object result = dtxLocalControl.doBusinessCode(info);

            // 4.4 业务执行成功
            txLogger.txTrace(info.getGroupId(), info.getUnitId(), "business success");
            dtxLocalControl.onBusinessCodeSuccess(info, result);
            return result;
        } catch (TransactionException e) {
            txLogger.error(info.getGroupId(), info.getUnitId(), "before business code error");
            throw e;
        } catch (Throwable e) {
            // 4.5 业务执行失败
            txLogger.error(info.getGroupId(), info.getUnitId(), Transactions.TAG_TRANSACTION,
                    "business code error");
            dtxLocalControl.onBusinessCodeError(info, e);
            throw e;
        } finally {
            // 4.6 业务执行完毕
            dtxLocalControl.postBusinessCode(info);
        }
    }
public Object transactionRunning(TxTransactionInfo info) throws Throwable {

        // 1. 获取事务类型
        String transactionType = info.getTransactionType();

        // 2. 获取事务传播状态
        DTXPropagationState propagationState = propagationResolver.resolvePropagationState(info);

        // 2.1 如果不参与分布式事务立即终止
        if (propagationState.isIgnored()) {
            return info.getBusinessCallback().call();
        }

        // 3. 获取本地分布式事务控制器
        DTXLocalControl dtxLocalControl = txLcnBeanHelper.loadDTXLocalControl(transactionType, propagationState);

        // 4. 织入事务操作
        try {
            // 4.1 记录事务类型到事务上下文
            Set<String> transactionTypeSet = globalContext.txContext(info.getGroupId()).getTransactionTypes();
            transactionTypeSet.add(transactionType);

            dtxLocalControl.preBusinessCode(info);

            // 4.2 业务执行前
            txLogger.txTrace(
                    info.getGroupId(), info.getUnitId(), "pre business code, unit type: {}", transactionType);

            // 4.3 执行业务
            Object result = dtxLocalControl.doBusinessCode(info);

            // 4.4 业务执行成功
            txLogger.txTrace(info.getGroupId(), info.getUnitId(), "business success");
            dtxLocalControl.onBusinessCodeSuccess(info, result);
            return result;
        } catch (TransactionException e) {
            txLogger.error(info.getGroupId(), info.getUnitId(), "before business code error");
            throw e;
        } catch (Throwable e) {
            // 4.5 业务执行失败
            txLogger.error(info.getGroupId(), info.getUnitId(), Transactions.TAG_TRANSACTION,
                    "business code error");
            dtxLocalControl.onBusinessCodeError(info, e);
            throw e;
        } finally {
            // 4.6 业务执行完毕
            dtxLocalControl.postBusinessCode(info);
        }
    }
public Object transactionRunning ( TxTransactionInfo info ) throws Throwable { // 1. 获取事务类型 String transactionType = info . getTransactionType ( ) ; // 2. 获取事务传播状态 DTXPropagationState propagationState = propagationResolver . resolvePropagationState ( info ) ; // 2.1 如果不参与分布式事务立即终止 if ( propagationState . isIgnored ( ) ) { return info . getBusinessCallback ( ) . call ( ) ; } // 3. 获取本地分布式事务控制器 DTXLocalControl dtxLocalControl = txLcnBeanHelper . loadDTXLocalControl ( transactionType , propagationState ) ; // 4. 织入事务操作 try { // 4.1 记录事务类型到事务上下文 Set < String > transactionTypeSet = globalContext . txContext ( info . getGroupId ( ) ) . getTransactionTypes ( ) ; transactionTypeSet . add ( transactionType ) ; dtxLocalControl . preBusinessCode ( info ) ; // 4.2 业务执行前 txLogger . txTrace ( info . getGroupId ( ) , info . getUnitId ( ) , "pre business code, unit type: {}" , transactionType ) ; // 4.3 执行业务 Object result = dtxLocalControl . doBusinessCode ( info ) ; // 4.4 业务执行成功 txLogger . txTrace ( info . getGroupId ( ) , info . getUnitId ( ) , "business success" ) ; dtxLocalControl . onBusinessCodeSuccess ( info , result ) ; return result ; } catch ( TransactionException e ) { txLogger . error ( info . getGroupId ( ) , info . getUnitId ( ) , "before business code error" ) ; throw e ; } catch ( Throwable e ) { // 4.5 业务执行失败 txLogger . error ( info . getGroupId ( ) , info . getUnitId ( ) , Transactions . TAG_TRANSACTION , "business code error" ) ; dtxLocalControl . onBusinessCodeError ( info , e ) ; throw e ; } finally { // 4.6 业务执行完毕 dtxLocalControl . postBusinessCode ( info ) ; } }
事务业务执行

@param info info
@return Object
@throws Throwable Throwable
事务业务执行