This is an automated email from the ASF dual-hosted git repository.

jianbin pushed a commit to branch 0614
in repository https://gitbox.apache.org/repos/asf/incubator-seata-samples.git

commit 94ddd886497ab6987fbeed2de0621e7350dc9178
Author: funky-eyes <jian...@apache.org>
AuthorDate: Sun Jun 15 01:36:26 2025 +0800

    add SagaAnnotation sample
---
 .../src/main/java/org/apache/seata/Main.java           |  8 ++++----
 .../action/{TccActionOne.java => SagaActionOne.java}   |  2 +-
 .../action/{TccActionTwo.java => SagaActionTwo.java}   |  2 +-
 .../{TccActionOneImpl.java => SagaActionOneImpl.java}  |  6 ++----
 .../{TccActionTwoImpl.java => SagaActionTwoImpl.java}  |  4 ++--
 ...sactionService.java => SagaTransactionService.java} | 18 +++++++++---------
 6 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/Main.java 
b/saga-annotation-sample/src/main/java/org/apache/seata/Main.java
index 1a25e7bc..6f10fa53 100644
--- a/saga-annotation-sample/src/main/java/org/apache/seata/Main.java
+++ b/saga-annotation-sample/src/main/java/org/apache/seata/Main.java
@@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.apache.seata.action.ResultHolder;
 import org.apache.seata.core.exception.TransactionException;
-import org.apache.seata.service.TccTransactionService;
+import org.apache.seata.service.SagaTransactionService;
 import org.apache.seata.tm.api.GlobalTransaction;
 import org.apache.seata.tm.api.GlobalTransactionContext;
 import org.springframework.boot.SpringApplication;
@@ -36,14 +36,14 @@ public class Main {
             throws IOException, ExecutionException, InterruptedException, 
TimeoutException, TransactionException {
         boolean isInE2ETest = isInE2ETest();
         ConfigurableApplicationContext context = 
SpringApplication.run(Main.class, args);
-        TccTransactionService tccTransactionService = 
context.getBean(TccTransactionService.class);
-        String xid = tccTransactionService.doTransactionCommit();
+        SagaTransactionService sagaTransactionService = 
context.getBean(SagaTransactionService.class);
+        String xid = sagaTransactionService.doTransactionCommit();
         ResultHolder.getActionTwoResult(xid).get(10, TimeUnit.SECONDS);
         GlobalTransaction globalTransaction = 
GlobalTransactionContext.createNew();
         globalTransaction.begin();
         xid = globalTransaction.getXid();
         try {
-           tccTransactionService.doTransactionRollback();
+            sagaTransactionService.doTransactionRollback();
         } catch (Exception e) {
             globalTransaction.rollback();
         }
diff --git 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionOne.java
 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java
similarity index 97%
rename from 
saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionOne.java
rename to 
saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java
index ad6be9a1..9c882a55 100644
--- 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionOne.java
+++ 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java
@@ -18,7 +18,7 @@ package org.apache.seata.action;
 
 import org.apache.seata.rm.tcc.api.BusinessActionContext;
 
-public interface TccActionOne {
+public interface SagaActionOne {
 
     /**
      * commit boolean.
diff --git 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionTwo.java
 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java
similarity index 97%
rename from 
saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionTwo.java
rename to 
saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java
index de9cd394..a75ce259 100644
--- 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/TccActionTwo.java
+++ 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java
@@ -20,7 +20,7 @@ import java.util.List;
 
 import org.apache.seata.rm.tcc.api.BusinessActionContext;
 
-public interface TccActionTwo {
+public interface SagaActionTwo {
 
     /**
      * commit boolean.
diff --git 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionOneImpl.java
 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java
similarity index 90%
rename from 
saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionOneImpl.java
rename to 
saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java
index bc496f15..b150ef22 100644
--- 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionOneImpl.java
+++ 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java
@@ -16,9 +16,7 @@
  */
 package org.apache.seata.action.impl;
 
-import java.util.concurrent.CompletableFuture;
-import org.apache.seata.action.ResultHolder;
-import org.apache.seata.action.TccActionOne;
+import org.apache.seata.action.SagaActionOne;
 import org.apache.seata.rm.tcc.api.BusinessActionContext;
 import org.apache.seata.rm.tcc.api.BusinessActionContextParameter;
 import org.apache.seata.rm.tcc.api.LocalTCC;
@@ -28,7 +26,7 @@ import org.springframework.util.Assert;
 
 @Service
 @LocalTCC
-public class TccActionOneImpl implements TccActionOne {
+public class SagaActionOneImpl implements SagaActionOne {
 
     @Override
     @CompensationBusinessAction(name = "DubboSagaActionOne", 
compensationMethod = "rollback")
diff --git 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionTwoImpl.java
 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.java
similarity index 96%
rename from 
saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionTwoImpl.java
rename to 
saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.java
index 8419523b..c500a634 100644
--- 
a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/TccActionTwoImpl.java
+++ 
b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.java
@@ -20,7 +20,7 @@ import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
 import org.apache.seata.action.ResultHolder;
-import org.apache.seata.action.TccActionTwo;
+import org.apache.seata.action.SagaActionTwo;
 import org.apache.seata.rm.tcc.api.BusinessActionContext;
 import org.apache.seata.rm.tcc.api.BusinessActionContextParameter;
 import org.apache.seata.rm.tcc.api.LocalTCC;
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
 
 @Service
 @LocalTCC
-public class TccActionTwoImpl implements TccActionTwo {
+public class SagaActionTwoImpl implements SagaActionTwo {
 
     @Override
     @CompensationBusinessAction(name = "DubboTccActionTwo", compensationMethod 
= "rollback")
diff --git 
a/saga-annotation-sample/src/main/java/org/apache/seata/service/TccTransactionService.java
 
b/saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java
similarity index 83%
rename from 
saga-annotation-sample/src/main/java/org/apache/seata/service/TccTransactionService.java
rename to 
saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java
index 42bdfb11..4b246506 100644
--- 
a/saga-annotation-sample/src/main/java/org/apache/seata/service/TccTransactionService.java
+++ 
b/saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java
@@ -19,8 +19,8 @@ package org.apache.seata.service;
 import java.util.ArrayList;
 import java.util.List;
 import javax.annotation.Resource;
-import org.apache.seata.action.TccActionOne;
-import org.apache.seata.action.TccActionTwo;
+import org.apache.seata.action.SagaActionOne;
+import org.apache.seata.action.SagaActionTwo;
 import org.apache.seata.core.context.RootContext;
 import org.apache.seata.spring.annotation.GlobalTransactional;
 import org.springframework.stereotype.Component;
@@ -31,13 +31,13 @@ import org.springframework.stereotype.Component;
  * @author zhangsen
  */
 @Component
-public class TccTransactionService {
+public class SagaTransactionService {
 
     @Resource
-    private TccActionOne tccActionOne;
+    private SagaActionOne sagaActionOne;
 
     @Resource
-    private TccActionTwo tccActionTwo;
+    private SagaActionTwo sagaActionTwo;
 
     /**
      * 发起分布式事务
@@ -47,14 +47,14 @@ public class TccTransactionService {
     @GlobalTransactional
     public String doTransactionCommit() {
         //第一个TCC 事务参与者
-        boolean result = tccActionOne.commit(null, 1);
+        boolean result = sagaActionOne.commit(null, 1);
         if (!result) {
             throw new RuntimeException("TccActionOne failed.");
         }
         List<String> list = new ArrayList<>();
         list.add("c1");
         list.add("c2");
-        result = tccActionTwo.commit(null, "two", list);
+        result = sagaActionTwo.commit(null, "two", list);
         if (!result) {
             throw new RuntimeException("TccActionTwo failed.");
         }
@@ -67,14 +67,14 @@ public class TccTransactionService {
     @GlobalTransactional
     public void doTransactionRollback() {
         //第一个TCC 事务参与者
-        boolean result = tccActionOne.commit(null, 1);
+        boolean result = sagaActionOne.commit(null, 1);
         if (!result) {
             throw new RuntimeException("TccActionOne failed.");
         }
         List<String> list = new ArrayList<>();
         list.add("c1");
         list.add("c2");
-        result = tccActionTwo.commit(null, "two", list);
+        result = sagaActionTwo.commit(null, "two", list);
         if (!result) {
             throw new RuntimeException("TccActionTwo failed.");
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to