use of io.seata.tm.api.GlobalTransaction in project seata by seata.
the class StateMachineDBTests method testCompensationStateMachineAsync.
@Disabled("https://github.com/seata/seata/issues/2564")
public void testCompensationStateMachineAsync() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleCompensationStateMachine";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()));
Assertions.assertTrue(ExecutionStatus.SU.equals(inst.getCompensationStatus()));
GlobalTransaction globalTransaction = getGlobalTransaction(inst);
Assertions.assertNotNull(globalTransaction);
Assertions.assertTrue(GlobalStatus.Finished.equals(globalTransaction.getStatus()));
}
use of io.seata.tm.api.GlobalTransaction in project seata by seata.
the class StateMachineDBTests method testStatusMatchingStateMachineAsync.
@Test
public void testStatusMatchingStateMachineAsync() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleStatusMatchingStateMachine";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertNotNull(inst.getException());
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()));
GlobalTransaction globalTransaction = getGlobalTransaction(inst);
Assertions.assertNotNull(globalTransaction);
Assertions.assertTrue(GlobalStatus.CommitRetrying.equals(globalTransaction.getStatus()));
}
use of io.seata.tm.api.GlobalTransaction in project seata by seata.
the class StateMachineDBTests method testSimpleCatchesStateMachine.
@Test
public void testSimpleCatchesStateMachine() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleCachesStateMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertNotNull(inst.getException());
Assertions.assertTrue(ExecutionStatus.FA.equals(inst.getStatus()));
GlobalTransaction globalTransaction = getGlobalTransaction(inst);
Assertions.assertNotNull(globalTransaction);
Assertions.assertTrue(GlobalStatus.Finished.equals(globalTransaction.getStatus()));
}
use of io.seata.tm.api.GlobalTransaction in project seata by seata.
the class StateMachineDBTests method testCompensationAndSubStateMachine.
@Test
public void testCompensationAndSubStateMachine() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 2);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleStateMachineWithCompensationAndSubMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()));
GlobalTransaction globalTransaction = getGlobalTransaction(inst);
Assertions.assertNotNull(globalTransaction);
Assertions.assertTrue(GlobalStatus.CommitRetrying.equals(globalTransaction.getStatus()));
}
use of io.seata.tm.api.GlobalTransaction in project seata by seata.
the class XAModeTest2 method createGlobalTransaction.
private GlobalTransaction createGlobalTransaction() {
String vgroup = "my_test_tx_group";
GlobalTransactionScanner scanner = new GlobalTransactionScanner(vgroup);
scanner.afterPropertiesSet();
GlobalTransaction gtx = GlobalTransactionContext.getCurrentOrCreate();
return gtx;
}
Aggregations