Search in sources :

Example 11 with GlobalTransaction

use of io.seata.tm.api.GlobalTransaction in project seata by seata.

the class XAModeTest2 method testStandardAppGlobalRollback.

@Test
@Disabled
public // Should RUN with local Seata Server
void testStandardAppGlobalRollback() throws Throwable {
    testCleanXARecover();
    doTestXAModeNormalPrepareData();
    // Create a standard proxy according to non-XA data source
    DataSource ds = createDataSourceProxyXA();
    // Create a global tx
    GlobalTransaction gtx = createGlobalTransaction();
    gtx.begin();
    runInGlobalTx(ds);
    gtx.rollback();
    Thread.sleep(5000);
}
Also used : GlobalTransaction(io.seata.tm.api.GlobalTransaction) XADataSource(javax.sql.XADataSource) MysqlXADataSource(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) DataSource(javax.sql.DataSource) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PGXADataSource(org.postgresql.xa.PGXADataSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 12 with GlobalTransaction

use of io.seata.tm.api.GlobalTransaction in project seata by seata.

the class XAModeTest2 method testStandardAppGlobalCommit.

@Test
@Disabled
public // Should RUN with local Seata Server
void testStandardAppGlobalCommit() throws Throwable {
    testCleanXARecover();
    doTestXAModeNormalPrepareData();
    // Create a standard proxy according to non-XA data source
    DataSource ds = createDataSourceProxyXA();
    // Create a global tx
    GlobalTransaction gtx = createGlobalTransaction();
    gtx.begin();
    runInGlobalTx(ds);
    gtx.commit();
    Thread.sleep(5000);
}
Also used : GlobalTransaction(io.seata.tm.api.GlobalTransaction) XADataSource(javax.sql.XADataSource) MysqlXADataSource(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) DataSource(javax.sql.DataSource) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PGXADataSource(org.postgresql.xa.PGXADataSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 13 with GlobalTransaction

use of io.seata.tm.api.GlobalTransaction in project seata by seata.

the class XAModeTest2 method testXANativeAppGlobalRollback.

@Test
@Disabled
public // Should RUN with local Seata Server
void testXANativeAppGlobalRollback() throws Throwable {
    testCleanXARecover();
    doTestXAModeNormalPrepareData();
    // Create a native proxy according to XA data source
    DataSource ds = createDataSourceProxyXANative();
    // Create a global tx
    GlobalTransaction gtx = createGlobalTransaction();
    gtx.begin();
    runInGlobalTx(ds);
    gtx.rollback();
    Thread.sleep(5000);
}
Also used : GlobalTransaction(io.seata.tm.api.GlobalTransaction) XADataSource(javax.sql.XADataSource) MysqlXADataSource(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) DataSource(javax.sql.DataSource) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PGXADataSource(org.postgresql.xa.PGXADataSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 14 with GlobalTransaction

use of io.seata.tm.api.GlobalTransaction in project seata by seata.

the class XAModeTest2 method testXANativeAppGlobalCommit.

@Test
@Disabled
public // Should RUN with local Seata Server
void testXANativeAppGlobalCommit() throws Throwable {
    testCleanXARecover();
    doTestXAModeNormalPrepareData();
    // Create a native proxy according to XA data source
    DataSource ds = createDataSourceProxyXANative();
    // Create a global tx
    GlobalTransaction gtx = createGlobalTransaction();
    gtx.begin();
    runInGlobalTx(ds);
    gtx.commit();
    Thread.sleep(5000);
}
Also used : GlobalTransaction(io.seata.tm.api.GlobalTransaction) XADataSource(javax.sql.XADataSource) MysqlXADataSource(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource) DataSource(javax.sql.DataSource) DruidXADataSource(com.alibaba.druid.pool.xa.DruidXADataSource) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) PGXADataSource(org.postgresql.xa.PGXADataSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 15 with GlobalTransaction

use of io.seata.tm.api.GlobalTransaction in project seata by seata.

the class StateMachineDBTests method getGlobalTransaction.

private GlobalTransaction getGlobalTransaction(StateMachineInstance instance) {
    GlobalTransaction globalTransaction = null;
    Map<String, Object> params = instance.getContext();
    if (params != null) {
        globalTransaction = (GlobalTransaction) params.get(DomainConstants.VAR_NAME_GLOBAL_TX);
    }
    if (globalTransaction == null) {
        try {
            globalTransaction = GlobalTransactionContext.reload(instance.getId());
        } catch (TransactionException e) {
            e.printStackTrace();
        }
    }
    return globalTransaction;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) GlobalTransaction(io.seata.tm.api.GlobalTransaction)

Aggregations

GlobalTransaction (io.seata.tm.api.GlobalTransaction)27 StateMachineInstance (io.seata.saga.statelang.domain.StateMachineInstance)17 Test (org.junit.jupiter.api.Test)13 HashMap (java.util.HashMap)10 Disabled (org.junit.jupiter.api.Disabled)7 EngineExecutionException (io.seata.saga.engine.exception.EngineExecutionException)6 TransactionException (io.seata.core.exception.TransactionException)5 ExecutionException (io.seata.tm.api.TransactionalExecutor.ExecutionException)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)4 DruidXADataSource (com.alibaba.druid.pool.xa.DruidXADataSource)4 MysqlXADataSource (com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)4 DataSource (javax.sql.DataSource)4 XADataSource (javax.sql.XADataSource)4 PGXADataSource (org.postgresql.xa.PGXADataSource)4 StateMachineConfig (io.seata.saga.engine.StateMachineConfig)3 DbStateMachineConfig (io.seata.saga.engine.config.DbStateMachineConfig)3 DefaultStateMachineConfig (io.seata.saga.engine.impl.DefaultStateMachineConfig)3 BranchStatus (io.seata.core.model.BranchStatus)1 GlobalStatus (io.seata.core.model.GlobalStatus)1 StateInstance (io.seata.saga.statelang.domain.StateInstance)1