Search in sources :

Example 1 with TCCSoftTransaction

use of com.dangdang.ddframe.rdb.transaction.soft.tcc.TCCSoftTransaction in project sharding-jdbc by dangdangdotcom.

the class SoftTransactionManager method getTransaction.

/**
     * 获取柔性事务管理器.
     * 
     * @param type 柔性事务类型
     * @return 柔性事务
     */
public AbstractSoftTransaction getTransaction(final SoftTransactionType type) {
    AbstractSoftTransaction result;
    switch(type) {
        case BestEffortsDelivery:
            result = new BEDSoftTransaction();
            break;
        case TryConfirmCancel:
            result = new TCCSoftTransaction();
            break;
        default:
            throw new UnsupportedOperationException(type.toString());
    }
    // TODO 目前使用不支持嵌套事务,以后这里需要可配置
    if (getCurrentTransaction().isPresent()) {
        throw new UnsupportedOperationException("Cannot support nested transaction.");
    }
    ExecutorDataMap.getDataMap().put(TRANSACTION, result);
    ExecutorDataMap.getDataMap().put(TRANSACTION_CONFIG, transactionConfig);
    return result;
}
Also used : BEDSoftTransaction(com.dangdang.ddframe.rdb.transaction.soft.bed.BEDSoftTransaction) TCCSoftTransaction(com.dangdang.ddframe.rdb.transaction.soft.tcc.TCCSoftTransaction)

Aggregations

BEDSoftTransaction (com.dangdang.ddframe.rdb.transaction.soft.bed.BEDSoftTransaction)1 TCCSoftTransaction (com.dangdang.ddframe.rdb.transaction.soft.tcc.TCCSoftTransaction)1