diff --git a/tcc/dubbo-tcc-sample/README.MD b/tcc-sample/dubbo-tcc-sample/README.MD
similarity index 100%
rename from tcc/dubbo-tcc-sample/README.MD
rename to tcc-sample/dubbo-tcc-sample/README.MD
diff --git a/tcc/dubbo-tcc-sample/pom.xml b/tcc-sample/dubbo-tcc-sample/pom.xml
similarity index 100%
rename from tcc/dubbo-tcc-sample/pom.xml
rename to tcc-sample/dubbo-tcc-sample/pom.xml
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/ResultHolder.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/ResultHolder.java
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/ResultHolder.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/ResultHolder.java
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java
similarity index 89%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java
index fa94fd28d..87293852d 100644
--- a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java
+++ b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionOne.java
@@ -29,12 +29,12 @@ public interface TccActionOne {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param a the a
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "DubboTccActionOne", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, @BusinessActionContextParameter(paramName = "a") int a);
+ public boolean prepare(@BusinessActionContextParameter(paramName = "a") int a);
/**
* Commit boolean.
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java
similarity index 90%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java
index 3caa016c3..4f72b94a8 100644
--- a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java
+++ b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/TccActionTwo.java
@@ -31,14 +31,13 @@ public interface TccActionTwo {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param b the b
* @param list the list
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "DubboTccActionTwo", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext,
- @BusinessActionContextParameter(paramName = "b") String b,
+ public boolean prepare(@BusinessActionContextParameter(paramName = "b") String b,
@BusinessActionContextParameter(paramName = "c", index = 1) List list);
/**
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java
similarity index 93%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java
index 427fc3cf4..88e58f587 100644
--- a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java
+++ b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionOneImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.samples.tcc.dubbo.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.dubbo.action.ResultHolder;
import io.seata.samples.tcc.dubbo.action.TccActionOne;
@@ -27,8 +28,8 @@
public class TccActionOneImpl implements TccActionOne {
@Override
- public boolean prepare(BusinessActionContext actionContext, int a) {
- String xid = actionContext.getXid();
+ public boolean prepare(int a) {
+ String xid = RootContext.getXID();
System.out.println("TccActionOne prepare, xid:" + xid + ", a:" + a);
return true;
}
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java
similarity index 93%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java
index c16474c7f..3263ddaa9 100644
--- a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java
+++ b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/action/impl/TccActionTwoImpl.java
@@ -17,6 +17,7 @@
import java.util.List;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.dubbo.action.ResultHolder;
import io.seata.samples.tcc.dubbo.action.TccActionTwo;
@@ -29,8 +30,8 @@
public class TccActionTwoImpl implements TccActionTwo {
@Override
- public boolean prepare(BusinessActionContext actionContext, String b, List list) {
- String xid = actionContext.getXid();
+ public boolean prepare(String b, List list) {
+ String xid = RootContext.getXID();
System.out.println("TccActionTwo prepare, xid:" + xid + ", b:" + b + ", c:" + list.get(1));
return true;
}
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java
similarity index 92%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java
index a92c255a3..9f3a5c3bc 100644
--- a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java
+++ b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/service/TccTransactionService.java
@@ -43,14 +43,14 @@ public class TccTransactionService {
@GlobalTransactional
public String doTransactionCommit() {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare(1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
List list = new ArrayList();
list.add("c1");
list.add("c2");
- result = tccActionTwo.prepare(null, "two", list);
+ result = tccActionTwo.prepare("two", list);
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
@@ -66,14 +66,14 @@ public String doTransactionCommit() {
@GlobalTransactional
public String doTransactionRollback(Map map) {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare( 1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
List list = new ArrayList();
list.add("c1");
list.add("c2");
- result = tccActionTwo.prepare(null, "two", list);
+ result = tccActionTwo.prepare("two", list);
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccConsumerStarter.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccConsumerStarter.java
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccConsumerStarter.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccConsumerStarter.java
diff --git a/tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccProviderStarter.java b/tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccProviderStarter.java
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccProviderStarter.java
rename to tcc-sample/dubbo-tcc-sample/src/main/java/io/seata/samples/tcc/dubbo/starter/TccProviderStarter.java
diff --git a/tcc/dubbo-tcc-sample/src/main/resources/file.conf b/tcc-sample/dubbo-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/dubbo-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/dubbo-tcc-sample/src/main/resources/registry.conf b/tcc-sample/dubbo-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/dubbo-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml b/tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
rename to tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
diff --git a/tcc/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml b/tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
rename to tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
diff --git a/tcc/dubbo-tcc-sample/src/main/resources/spring/seata-tcc.xml b/tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-tcc.xml
similarity index 100%
rename from tcc/dubbo-tcc-sample/src/main/resources/spring/seata-tcc.xml
rename to tcc-sample/dubbo-tcc-sample/src/main/resources/spring/seata-tcc.xml
diff --git a/tcc/hsf-tcc-sample/1.png b/tcc-sample/hsf-tcc-sample/1.png
similarity index 100%
rename from tcc/hsf-tcc-sample/1.png
rename to tcc-sample/hsf-tcc-sample/1.png
diff --git a/tcc/hsf-tcc-sample/2.png b/tcc-sample/hsf-tcc-sample/2.png
similarity index 100%
rename from tcc/hsf-tcc-sample/2.png
rename to tcc-sample/hsf-tcc-sample/2.png
diff --git a/tcc/hsf-tcc-sample/3.png b/tcc-sample/hsf-tcc-sample/3.png
similarity index 100%
rename from tcc/hsf-tcc-sample/3.png
rename to tcc-sample/hsf-tcc-sample/3.png
diff --git a/tcc/hsf-tcc-sample/README.md b/tcc-sample/hsf-tcc-sample/README.md
similarity index 100%
rename from tcc/hsf-tcc-sample/README.md
rename to tcc-sample/hsf-tcc-sample/README.md
diff --git a/tcc/hsf-tcc-sample/pom.xml b/tcc-sample/hsf-tcc-sample/pom.xml
similarity index 100%
rename from tcc/hsf-tcc-sample/pom.xml
rename to tcc-sample/hsf-tcc-sample/pom.xml
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/IndexServlet.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/IndexServlet.java
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/IndexServlet.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/IndexServlet.java
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/StartListener.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/StartListener.java
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/StartListener.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/carshop/StartListener.java
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java
similarity index 89%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java
index 22215499e..68ca3b228 100644
--- a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java
+++ b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionOne.java
@@ -28,12 +28,12 @@ public interface ActionOne {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param a the a
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "TccActionOne", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, @BusinessActionContextParameter(paramName = "a") int a);
+ public boolean prepare(@BusinessActionContextParameter(paramName = "a") int a);
/**
* Commit boolean.
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java
similarity index 90%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java
index 6dcde7216..1256ae575 100644
--- a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java
+++ b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/ActionTwo.java
@@ -30,14 +30,13 @@ public interface ActionTwo {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param b the b
* @param list the list
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "TccActionTwo", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext,
- @BusinessActionContextParameter(paramName = "b") String b,
+ public boolean prepare(@BusinessActionContextParameter(paramName = "b") String b,
@BusinessActionContextParameter(paramName = "c", index = 1) List list);
/**
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java
similarity index 92%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java
index 71b7775fd..5385af394 100644
--- a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java
+++ b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionOneImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.edas.tcc.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.edas.tcc.action.ActionOne;
import io.seata.rm.tcc.api.BusinessActionContext;
@@ -26,8 +27,8 @@
public class ActionOneImpl implements ActionOne {
@Override
- public boolean prepare(BusinessActionContext actionContext, int a) {
- String xid = actionContext.getXid();
+ public boolean prepare(int a) {
+ String xid = RootContext.getXID();
System.out.println("TccActionOne prepare, xid:" + xid + ", a:" + a);
return true;
}
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java
similarity index 92%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java
index 8175097b1..6f9a22be8 100644
--- a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java
+++ b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/action/impl/ActionTwoImpl.java
@@ -17,6 +17,7 @@
import java.util.List;
+import io.seata.core.context.RootContext;
import io.seata.edas.tcc.action.ActionTwo;
import io.seata.rm.tcc.api.BusinessActionContext;
@@ -28,8 +29,8 @@
public class ActionTwoImpl implements ActionTwo {
@Override
- public boolean prepare(BusinessActionContext actionContext, String b, List list) {
- String xid = actionContext.getXid();
+ public boolean prepare(String b, List list) {
+ String xid = RootContext.getXID();
System.out.println("TccActionTwo prepare, xid:" + xid + ", b:" + b + ", c:" + list.get(1));
return true;
}
diff --git a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java
similarity index 94%
rename from tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java
rename to tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java
index e4c18d039..4198003fb 100644
--- a/tcc/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java
+++ b/tcc-sample/hsf-tcc-sample/src/main/java/io/seata/edas/tcc/activity/ActivityServiceImpl.java
@@ -36,7 +36,7 @@ public class ActivityServiceImpl {
@GlobalTransactional
public String doActivity(boolean commit) {
//第一个TCC 事务参与者
- boolean result = actionOne.prepare(null, 1);
+ boolean result = actionOne.prepare(1);
if (!commit || !result) {
throw new RuntimeException("TccActionOne failed.");
}
@@ -45,7 +45,7 @@ public String doActivity(boolean commit) {
List list = new ArrayList();
list.add("c1");
list.add("c2");
- result = actionTwo.prepare(null, "two", list);
+ result = actionTwo.prepare("two", list);
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
diff --git a/tcc/hsf-tcc-sample/src/main/resources/file.conf b/tcc-sample/hsf-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/hsf-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/hsf-tcc-sample/src/main/resources/registry.conf b/tcc-sample/hsf-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/hsf-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/hsf-tcc-sample/src/main/resources/spring/hsf-beans.xml b/tcc-sample/hsf-tcc-sample/src/main/resources/spring/hsf-beans.xml
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/resources/spring/hsf-beans.xml
rename to tcc-sample/hsf-tcc-sample/src/main/resources/spring/hsf-beans.xml
diff --git a/tcc/hsf-tcc-sample/src/main/webapp/WEB-INF/logging.properties b/tcc-sample/hsf-tcc-sample/src/main/webapp/WEB-INF/logging.properties
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/webapp/WEB-INF/logging.properties
rename to tcc-sample/hsf-tcc-sample/src/main/webapp/WEB-INF/logging.properties
diff --git a/tcc/hsf-tcc-sample/src/main/webapp/WEB-INF/web.xml b/tcc-sample/hsf-tcc-sample/src/main/webapp/WEB-INF/web.xml
similarity index 100%
rename from tcc/hsf-tcc-sample/src/main/webapp/WEB-INF/web.xml
rename to tcc-sample/hsf-tcc-sample/src/main/webapp/WEB-INF/web.xml
diff --git a/tcc/hsf-tcc-sample/src/test/java/io/seata/edas/MockSeataServer.java b/tcc-sample/hsf-tcc-sample/src/test/java/io/seata/edas/MockSeataServer.java
similarity index 100%
rename from tcc/hsf-tcc-sample/src/test/java/io/seata/edas/MockSeataServer.java
rename to tcc-sample/hsf-tcc-sample/src/test/java/io/seata/edas/MockSeataServer.java
diff --git a/tcc/local-tcc-sample/README.MD b/tcc-sample/local-tcc-sample/README.MD
similarity index 100%
rename from tcc/local-tcc-sample/README.MD
rename to tcc-sample/local-tcc-sample/README.MD
diff --git a/tcc/local-tcc-sample/pom.xml b/tcc-sample/local-tcc-sample/pom.xml
similarity index 100%
rename from tcc/local-tcc-sample/pom.xml
rename to tcc-sample/local-tcc-sample/pom.xml
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/ApplicationKeeper.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/ApplicationKeeper.java
similarity index 100%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/ApplicationKeeper.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/ApplicationKeeper.java
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/ResultHolder.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/ResultHolder.java
similarity index 100%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/ResultHolder.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/ResultHolder.java
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java
similarity index 92%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java
index 9b0e16b7a..9134b1683 100644
--- a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java
+++ b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionOne.java
@@ -30,12 +30,12 @@ public interface TccActionOne {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param a the a
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "TccActionOne", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, int a);
+ public boolean prepare(int a);
/**
* Commit boolean.
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java
similarity index 92%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java
index 673e2f431..3b1c12809 100644
--- a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java
+++ b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/TccActionTwo.java
@@ -30,12 +30,12 @@ public interface TccActionTwo {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param b the b
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "TccActionTwo", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, String b);
+ public boolean prepare(String b);
/**
* Commit boolean.
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java
similarity index 92%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java
index a00047c5d..eaa9d4e78 100644
--- a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java
+++ b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionOneImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.samples.tcc.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.action.ResultHolder;
import io.seata.samples.tcc.action.TccActionOne;
@@ -27,8 +28,8 @@
public class TccActionOneImpl implements TccActionOne {
@Override
- public boolean prepare(BusinessActionContext actionContext, int a) {
- String xid = actionContext.getXid();
+ public boolean prepare(int a) {
+ String xid = RootContext.getXID();
System.out.println("TccActionOne prepare, xid:" + xid);
return true;
}
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java
similarity index 92%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java
index f1d1e0e91..af7b49e6e 100644
--- a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java
+++ b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/action/impl/TccActionTwoImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.samples.tcc.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.action.ResultHolder;
import io.seata.samples.tcc.action.TccActionTwo;
@@ -27,8 +28,8 @@
public class TccActionTwoImpl implements TccActionTwo {
@Override
- public boolean prepare(BusinessActionContext actionContext, String b) {
- String xid = actionContext.getXid();
+ public boolean prepare(String b) {
+ String xid = RootContext.getXID();
System.out.println("TccActionTwo prepare, xid:" + xid);
return true;
}
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java
similarity index 91%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java
index 0abb340dc..2bbe7f229 100644
--- a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java
+++ b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/service/TccTransactionService.java
@@ -41,11 +41,11 @@ public class TccTransactionService {
@GlobalTransactional
public String doTransactionCommit() {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare( 1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
- result = tccActionTwo.prepare(null, "two");
+ result = tccActionTwo.prepare( "two");
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
@@ -61,11 +61,11 @@ public String doTransactionCommit() {
@GlobalTransactional
public String doTransactionRollback(Map map) {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare( 1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
- result = tccActionTwo.prepare(null, "two");
+ result = tccActionTwo.prepare( "two");
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
diff --git a/tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/starter/LocalTccTransactionStarter.java b/tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/starter/LocalTccTransactionStarter.java
similarity index 100%
rename from tcc/local-tcc-sample/src/main/java/io/seata/samples/tcc/starter/LocalTccTransactionStarter.java
rename to tcc-sample/local-tcc-sample/src/main/java/io/seata/samples/tcc/starter/LocalTccTransactionStarter.java
diff --git a/tcc/local-tcc-sample/src/main/resources/file.conf b/tcc-sample/local-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/local-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/local-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/local-tcc-sample/src/main/resources/registry.conf b/tcc-sample/local-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/local-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/local-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/local-tcc-sample/src/main/resources/spring/seata-tcc.xml b/tcc-sample/local-tcc-sample/src/main/resources/spring/seata-tcc.xml
similarity index 100%
rename from tcc/local-tcc-sample/src/main/resources/spring/seata-tcc.xml
rename to tcc-sample/local-tcc-sample/src/main/resources/spring/seata-tcc.xml
diff --git a/tcc/local-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java b/tcc-sample/local-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java
similarity index 100%
rename from tcc/local-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java
rename to tcc-sample/local-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java
diff --git a/tcc/pom.xml b/tcc-sample/pom.xml
similarity index 100%
rename from tcc/pom.xml
rename to tcc-sample/pom.xml
diff --git a/tcc/sofarpc-tcc-sample/README.MD b/tcc-sample/sofarpc-tcc-sample/README.MD
similarity index 100%
rename from tcc/sofarpc-tcc-sample/README.MD
rename to tcc-sample/sofarpc-tcc-sample/README.MD
diff --git a/tcc/sofarpc-tcc-sample/pom.xml b/tcc-sample/sofarpc-tcc-sample/pom.xml
similarity index 100%
rename from tcc/sofarpc-tcc-sample/pom.xml
rename to tcc-sample/sofarpc-tcc-sample/pom.xml
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/ApplicationKeeper.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/ApplicationKeeper.java
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/ApplicationKeeper.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/ApplicationKeeper.java
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/ResultHolder.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/ResultHolder.java
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/ResultHolder.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/ResultHolder.java
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java
similarity index 87%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java
index a81e9d52c..0439c8bc4 100644
--- a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java
+++ b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionOne.java
@@ -13,12 +13,12 @@ public interface TccActionOne {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param a the a
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "SofaRpcTccActionOne", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, int a);
+ public boolean prepare(int a);
/**
* Commit boolean.
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java
similarity index 87%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java
index 760b47e2d..8263abe8e 100644
--- a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java
+++ b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/TccActionTwo.java
@@ -13,12 +13,12 @@ public interface TccActionTwo {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param b the b
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "SofaRpcTccActionTwo", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, String b);
+ public boolean prepare(String b);
/**
* Commit boolean.
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java
similarity index 88%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java
index bd9af01f3..874f49ea1 100644
--- a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java
+++ b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionOneImpl.java
@@ -1,6 +1,7 @@
package io.seata.samples.tcc.sofarpc.action.impl;
import io.seata.rm.tcc.api.BusinessActionContext;
+import io.seata.core.context.RootContext;
import io.seata.samples.tcc.sofarpc.action.ResultHolder;
import io.seata.samples.tcc.sofarpc.action.TccActionOne;
@@ -12,8 +13,8 @@
public class TccActionOneImpl implements TccActionOne {
@Override
- public boolean prepare(BusinessActionContext actionContext, int a) {
- String txId = actionContext.getXid();
+ public boolean prepare(int a) {
+ String txId = RootContext.getXID();
System.out.println("TccActionOne prepare, txId:" + txId);
return true;
}
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java
similarity index 88%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java
index 3c019c7a8..7a9e9c900 100644
--- a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java
+++ b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/action/impl/TccActionTwoImpl.java
@@ -1,6 +1,7 @@
package io.seata.samples.tcc.sofarpc.action.impl;
import io.seata.rm.tcc.api.BusinessActionContext;
+import io.seata.core.context.RootContext;
import io.seata.samples.tcc.sofarpc.action.ResultHolder;
import io.seata.samples.tcc.sofarpc.action.TccActionTwo;
@@ -12,8 +13,8 @@
public class TccActionTwoImpl implements TccActionTwo {
@Override
- public boolean prepare(BusinessActionContext actionContext, String b) {
- String txId = actionContext.getXid();
+ public boolean prepare(String b) {
+ String txId = RootContext.getXID();
System.out.println("TccActionTwo prepare, xid:" + txId);
return true;
}
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java
similarity index 89%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java
index 69cf64d8e..59c7a6c45 100644
--- a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java
+++ b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/service/TccTransactionService.java
@@ -26,11 +26,11 @@ public class TccTransactionService {
@GlobalTransactional
public String doTransactionCommit() {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare( 1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
- result = tccActionTwo.prepare(null, "two");
+ result = tccActionTwo.prepare("two");
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
@@ -46,11 +46,11 @@ public String doTransactionCommit() {
@GlobalTransactional
public String doTransactionRollback(Map map) {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare(1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
- result = tccActionTwo.prepare(null, "two");
+ result = tccActionTwo.prepare("two");
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
diff --git a/tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/starter/SofaRPCTccTransactionApplication.java b/tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/starter/SofaRPCTccTransactionApplication.java
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/starter/SofaRPCTccTransactionApplication.java
rename to tcc-sample/sofarpc-tcc-sample/src/main/java/io/seata/samples/tcc/sofarpc/starter/SofaRPCTccTransactionApplication.java
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/application.properties b/tcc-sample/sofarpc-tcc-sample/src/main/resources/application.properties
old mode 100755
new mode 100644
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/application.properties
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/application.properties
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/file.conf b/tcc-sample/sofarpc-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/provider/seata-sofarpc-provider.xml b/tcc-sample/sofarpc-tcc-sample/src/main/resources/provider/seata-sofarpc-provider.xml
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/provider/seata-sofarpc-provider.xml
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/provider/seata-sofarpc-provider.xml
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/provider/seata-tcc.xml b/tcc-sample/sofarpc-tcc-sample/src/main/resources/provider/seata-tcc.xml
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/provider/seata-tcc.xml
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/provider/seata-tcc.xml
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/registry.conf b/tcc-sample/sofarpc-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/spring/seata-sofarpc-reference.xml b/tcc-sample/sofarpc-tcc-sample/src/main/resources/spring/seata-sofarpc-reference.xml
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/spring/seata-sofarpc-reference.xml
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/spring/seata-sofarpc-reference.xml
diff --git a/tcc/sofarpc-tcc-sample/src/main/resources/spring/seata-tcc.xml b/tcc-sample/sofarpc-tcc-sample/src/main/resources/spring/seata-tcc.xml
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/main/resources/spring/seata-tcc.xml
rename to tcc-sample/sofarpc-tcc-sample/src/main/resources/spring/seata-tcc.xml
diff --git a/tcc/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SofaRpcTccProviderApplication.java b/tcc-sample/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SofaRpcTccProviderApplication.java
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SofaRpcTccProviderApplication.java
rename to tcc-sample/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SofaRpcTccProviderApplication.java
diff --git a/tcc/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java b/tcc-sample/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
similarity index 100%
rename from tcc/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
rename to tcc-sample/sofarpc-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
diff --git a/tcc/springboot-tcc-sample/README.MD b/tcc-sample/springboot-tcc-sample/README.MD
similarity index 100%
rename from tcc/springboot-tcc-sample/README.MD
rename to tcc-sample/springboot-tcc-sample/README.MD
diff --git a/tcc/springboot-tcc-sample/pom.xml b/tcc-sample/springboot-tcc-sample/pom.xml
similarity index 100%
rename from tcc/springboot-tcc-sample/pom.xml
rename to tcc-sample/springboot-tcc-sample/pom.xml
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/ApplicationKeeper.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/ApplicationKeeper.java
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/ApplicationKeeper.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/ApplicationKeeper.java
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/ResultHolder.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/ResultHolder.java
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/ResultHolder.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/ResultHolder.java
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java
similarity index 84%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java
index a7f5abcdb..6dc6054ef 100644
--- a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java
+++ b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionOne.java
@@ -14,12 +14,12 @@ public interface TccActionOne {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param a the a
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "DubboTccActionOne", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext, @BusinessActionContextParameter(paramName = "a") int a);
+ public boolean prepare(@BusinessActionContextParameter(paramName = "a") int a);
/**
* Commit boolean.
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java
similarity index 86%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java
index 28cb0fd5e..b311ce407 100644
--- a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java
+++ b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/TccActionTwo.java
@@ -16,14 +16,13 @@ public interface TccActionTwo {
/**
* Prepare boolean.
*
- * @param actionContext the action context
+ *
* @param b the b
* @param list the list
* @return the boolean
*/
@TwoPhaseBusinessAction(name = "DubboTccActionTwo", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepare(BusinessActionContext actionContext,
- @BusinessActionContextParameter(paramName = "b") String b,
+ public boolean prepare(@BusinessActionContextParameter(paramName = "b") String b,
@BusinessActionContextParameter(paramName = "c", index = 1) List list);
/**
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java
similarity index 90%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java
index 3a49b6816..ccd529d19 100644
--- a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java
+++ b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionOneImpl.java
@@ -1,5 +1,6 @@
package io.seata.samples.tcc.springboot.dubbo.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.springboot.dubbo.action.ResultHolder;
import io.seata.samples.tcc.springboot.dubbo.action.TccActionOne;
@@ -12,8 +13,8 @@
public class TccActionOneImpl implements TccActionOne {
@Override
- public boolean prepare(BusinessActionContext actionContext, int a) {
- String xid = actionContext.getXid();
+ public boolean prepare(int a) {
+ String xid = RootContext.getXID();
System.out.println("TccActionOne prepare, xid:" + xid + ", a:" + a);
return true;
}
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java
similarity index 90%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java
index 81adb7262..22d8eb9a0 100644
--- a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java
+++ b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/action/impl/TccActionTwoImpl.java
@@ -2,6 +2,7 @@
import java.util.List;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.springboot.dubbo.action.ResultHolder;
import io.seata.samples.tcc.springboot.dubbo.action.TccActionTwo;
@@ -14,8 +15,8 @@
public class TccActionTwoImpl implements TccActionTwo {
@Override
- public boolean prepare(BusinessActionContext actionContext, String b, List list) {
- String xid = actionContext.getXid();
+ public boolean prepare(String b, List list) {
+ String xid = RootContext.getXID();
System.out.println("TccActionTwo prepare, xid:" + xid + ", b:" + b + ", c:" + list.get(1));
return true;
}
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java
similarity index 90%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java
index bb678f426..f3a66693d 100644
--- a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java
+++ b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/service/TccTransactionService.java
@@ -28,14 +28,14 @@ public class TccTransactionService {
@GlobalTransactional
public String doTransactionCommit() {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare(1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
List list = new ArrayList();
list.add("c1");
list.add("c2");
- result = tccActionTwo.prepare(null, "two", list);
+ result = tccActionTwo.prepare("two", list);
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
@@ -51,14 +51,14 @@ public String doTransactionCommit() {
@GlobalTransactional
public String doTransactionRollback(Map map) {
//第一个TCC 事务参与者
- boolean result = tccActionOne.prepare(null, 1);
+ boolean result = tccActionOne.prepare(1);
if (!result) {
throw new RuntimeException("TccActionOne failed.");
}
List list = new ArrayList();
list.add("c1");
list.add("c2");
- result = tccActionTwo.prepare(null, "two", list);
+ result = tccActionTwo.prepare("two", list);
if (!result) {
throw new RuntimeException("TccActionTwo failed.");
}
diff --git a/tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/starter/SpringbootTccTransactionApplication.java b/tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/starter/SpringbootTccTransactionApplication.java
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/starter/SpringbootTccTransactionApplication.java
rename to tcc-sample/springboot-tcc-sample/src/main/java/io/seata/samples/tcc/springboot/dubbo/starter/SpringbootTccTransactionApplication.java
diff --git a/tcc/springboot-tcc-sample/src/main/resources/application.properties b/tcc-sample/springboot-tcc-sample/src/main/resources/application.properties
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/application.properties
rename to tcc-sample/springboot-tcc-sample/src/main/resources/application.properties
diff --git a/tcc/springboot-tcc-sample/src/main/resources/file.conf b/tcc-sample/springboot-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/springboot-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/springboot-tcc-sample/src/main/resources/provider/seata-dubbo-provider.xml b/tcc-sample/springboot-tcc-sample/src/main/resources/provider/seata-dubbo-provider.xml
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/provider/seata-dubbo-provider.xml
rename to tcc-sample/springboot-tcc-sample/src/main/resources/provider/seata-dubbo-provider.xml
diff --git a/tcc/springboot-tcc-sample/src/main/resources/provider/seata-tcc.xml b/tcc-sample/springboot-tcc-sample/src/main/resources/provider/seata-tcc.xml
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/provider/seata-tcc.xml
rename to tcc-sample/springboot-tcc-sample/src/main/resources/provider/seata-tcc.xml
diff --git a/tcc/springboot-tcc-sample/src/main/resources/registry.conf b/tcc-sample/springboot-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/springboot-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/springboot-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml b/tcc-sample/springboot-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
rename to tcc-sample/springboot-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
diff --git a/tcc/springboot-tcc-sample/src/main/resources/spring/seata-tcc.xml b/tcc-sample/springboot-tcc-sample/src/main/resources/spring/seata-tcc.xml
similarity index 100%
rename from tcc/springboot-tcc-sample/src/main/resources/spring/seata-tcc.xml
rename to tcc-sample/springboot-tcc-sample/src/main/resources/spring/seata-tcc.xml
diff --git a/tcc/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SpringbootTccProviderApplication.java b/tcc-sample/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SpringbootTccProviderApplication.java
similarity index 100%
rename from tcc/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SpringbootTccProviderApplication.java
rename to tcc-sample/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/provider/SpringbootTccProviderApplication.java
diff --git a/tcc/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java b/tcc-sample/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
similarity index 100%
rename from tcc/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
rename to tcc-sample/springboot-tcc-sample/src/test/java/io/seata/samples/tcc/server/SeataServerStarter.java
diff --git a/tcc-sample/suspend-tcc-sample/account/pom.xml b/tcc-sample/suspend-tcc-sample/account/pom.xml
new file mode 100644
index 000000000..695292fca
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/pom.xml
@@ -0,0 +1,91 @@
+
+
+
+ seata-springcloud-nacos-sample
+ io.seata
+ 1.1.0
+
+ 4.0.0
+ com.seata.account
+ account-service
+ 1.0.0-SNAPSHOT
+ account-service
+ 账户服务
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-seata
+
+
+ io.seata
+ seata-spring-boot-starter
+
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.5.2
+
+
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ tk.mybatis
+ mapper
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.2.3
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/AccountApplication.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/AccountApplication.java
new file mode 100644
index 000000000..ecd8b0244
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/AccountApplication.java
@@ -0,0 +1,20 @@
+package com.seata.account;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import tk.mybatis.spring.annotation.MapperScan;
+
+@SpringBootApplication
+@MapperScan("com.seata.account.mapper")
+@EnableDiscoveryClient
+@EnableFeignClients
+public class AccountApplication {
+
+
+ public static void main(String[] args) {
+ SpringApplication.run(AccountApplication.class, args);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/controller/AccountController.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/controller/AccountController.java
new file mode 100644
index 000000000..d9a201774
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/controller/AccountController.java
@@ -0,0 +1,27 @@
+package com.seata.account.controller;
+
+
+import com.seata.account.service.AccountService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController
+public class AccountController {
+ @Autowired
+ private AccountService accountService;
+
+ @GetMapping("account/occupy")
+ public void occupy(String userId, int money){
+
+ accountService.occupy(userId,money);
+ };
+
+ @GetMapping("account/rollBackAccount")
+ public void rollBackAccount(String userId, int money){
+ accountService.rollBackAccount(userId,money);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/mapper/AccountMapper.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/mapper/AccountMapper.java
new file mode 100644
index 000000000..638d91cdc
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/mapper/AccountMapper.java
@@ -0,0 +1,28 @@
+package com.seata.account.mapper;
+
+
+import com.seata.account.model.Account;
+
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Repository;
+import tk.mybatis.mapper.common.Mapper;
+
+
+@Repository
+public interface AccountMapper extends Mapper {
+
+ /**
+ * 从用户账户中借出
+ */
+ @Update("update account_tbl set money = money - #{money} where user_id = #{userId}")
+ void occupy(String userId, int money);
+
+
+ /**
+ * 从用户账户中回滚扣除的金额
+ */
+ @Update("update account_tbl set money = money + #{money} where user_id = #{userId}")
+ void rollBackAccount(String userId, int money);
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/model/Account.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/model/Account.java
new file mode 100644
index 000000000..f517691dd
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/model/Account.java
@@ -0,0 +1,25 @@
+package com.seata.account.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Table(name = "account_tbl")
+@Data
+@Accessors(chain = true)
+public class Account {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ private String userId;
+
+ private Integer money;
+
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/AccountService.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/AccountService.java
new file mode 100644
index 000000000..440dd2edf
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/AccountService.java
@@ -0,0 +1,10 @@
+package com.seata.account.service;
+
+
+
+public interface AccountService {
+
+ void occupy(String userId, int money);
+
+ void rollBackAccount(String userId, int money);
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/impl/AccountServiceImpl.java b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..97849536c
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/java/com/seata/account/service/impl/AccountServiceImpl.java
@@ -0,0 +1,29 @@
+package com.seata.account.service.impl;
+
+
+import com.seata.account.mapper.AccountMapper;
+import com.seata.account.service.AccountService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+@Slf4j
+@Service
+public class AccountServiceImpl implements AccountService {
+
+ @Autowired
+ private AccountMapper accountMapper;
+
+
+ @Override
+ public void occupy(String userId, int money) {
+ accountMapper.occupy(userId,money);
+ }
+
+ @Override
+ public void rollBackAccount(String userId, int money) {
+ accountMapper.rollBackAccount(userId,money);
+ }
+}
diff --git a/tcc-sample/suspend-tcc-sample/account/src/main/resources/bootstrap.yml b/tcc-sample/suspend-tcc-sample/account/src/main/resources/bootstrap.yml
new file mode 100644
index 000000000..c2fddef5c
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/account/src/main/resources/bootstrap.yml
@@ -0,0 +1,53 @@
+server:
+ port: 6760
+spring:
+ application:
+ name: account-service
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ password: root
+ url: jdbc:mysql://127.0.0.1:3306/seata_samples?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ register-enabled: true
+ namespace:
+ config:
+ server-addr: 127.0.0.1:8848
+ enabled: true
+ file-extension: yaml
+ namespace:
+
+seata:
+ enabled: true
+ application-id: ${spring.application.name}
+ # 事务群组(可以每个应用独立取名,也可以使用相同的名字),要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+ tx-service-group: ${spring.application.name}-tx-group
+ service:
+ vgroup-mapping:
+ account-service-tx-group: "default"
+ config:
+ type: file
+ # 需要和server在同一个注册中心下
+ nacos:
+ namespace:
+ serverAddr: 127.0.0.1:8848
+ # 需要server端(registry和config)、nacos配置client端(registry和config)保持一致
+ group: SEATA_GROUP
+ username: "nacos"
+ password: "nacos"
+ registry:
+ type: nacos
+ nacos:
+ # 需要和server端保持一致,即server在nacos中的名称,默认为seata-server
+ application: seata-server
+ server-addr: 127.0.0.1:8848
+ group: SEATA_GROUP
+ namespace:
+ username: "nacos"
+ password: "nacos"
+
+mybatis:
+ mapperLocations: classpath:mapper/*.xml
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/business/pom.xml b/tcc-sample/suspend-tcc-sample/business/pom.xml
new file mode 100644
index 000000000..960f068e3
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/pom.xml
@@ -0,0 +1,90 @@
+
+
+
+ seata-springcloud-nacos-sample
+ io.seata
+ 1.1.0
+
+ 4.0.0
+ com.seata.business
+ business-service
+ 1.0.0-SNAPSHOT
+ business-service
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-seata
+
+
+ io.seata
+ seata-spring-boot-starter
+
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.5.2
+
+
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ tk.mybatis
+ mapper
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.2.3
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/BusinessApplication.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/BusinessApplication.java
new file mode 100644
index 000000000..856db6ab2
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/BusinessApplication.java
@@ -0,0 +1,19 @@
+package com.seata.business;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients
+public class BusinessApplication {
+
+
+ public static void main(String[] args) {
+ SpringApplication.run(BusinessApplication.class, args);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/AccountClient.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/AccountClient.java
new file mode 100644
index 000000000..199ece35e
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/AccountClient.java
@@ -0,0 +1,19 @@
+package com.seata.business.client;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+
+@FeignClient(name = "account-service")
+@Component
+public interface AccountClient {
+
+ @GetMapping("account/occupy")
+ public void occupy(@RequestParam("userId") String userId, @RequestParam("money")int money);
+
+ @GetMapping("account/rollBackAccount")
+ public void rollBackAccount(@RequestParam("userId") String userId, @RequestParam("money")int money);
+
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/InventoryClient.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/InventoryClient.java
new file mode 100644
index 000000000..d5e241d57
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/InventoryClient.java
@@ -0,0 +1,22 @@
+package com.seata.business.client;
+
+
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+
+@FeignClient(name = "inventory-service")
+@Component
+public interface InventoryClient {
+
+ @GetMapping("inventory/occupy")
+ public void occupy(@RequestParam("commodityCode") String commodityCode , @RequestParam("count") int count);
+
+ @GetMapping("inventory/rollBackInventory")
+ public void rollBackInventory(@RequestParam("commodityCode") String commodityCode , @RequestParam("count") int count);
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/OrderClient.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/OrderClient.java
new file mode 100644
index 000000000..259b23750
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/client/OrderClient.java
@@ -0,0 +1,18 @@
+package com.seata.business.client;
+
+import com.seata.business.model.Order;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+
+@FeignClient(name = "order-service")
+@Component
+public interface OrderClient {
+
+ @PostMapping("order/create")
+ public Boolean create(@RequestBody Order order);
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/controller/BusinessController.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/controller/BusinessController.java
new file mode 100644
index 000000000..bf24fb236
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/controller/BusinessController.java
@@ -0,0 +1,22 @@
+package com.seata.business.controller;
+
+
+import com.seata.business.service.BusinessService;
+import io.seata.spring.annotation.GlobalTransactional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class BusinessController {
+
+ @Autowired
+ private BusinessService businessService;
+
+ @GetMapping("business/buy")
+ @GlobalTransactional
+ public String buy( String userId, String commodityCode, int count){
+ return businessService.prepareBuy(userId,commodityCode,count);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/model/Order.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/model/Order.java
new file mode 100644
index 000000000..6cba50734
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/model/Order.java
@@ -0,0 +1,19 @@
+package com.seata.business.model;
+
+import lombok.Data;
+
+@Data
+public class Order {
+
+
+ private Integer id;
+
+ private String userId;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ private Integer money;
+
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/BusinessService.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/BusinessService.java
new file mode 100644
index 000000000..8a394baea
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/BusinessService.java
@@ -0,0 +1,29 @@
+package com.seata.business.service;
+
+
+import io.seata.rm.tcc.api.BusinessActionContext;
+import io.seata.rm.tcc.api.BusinessActionContextParameter;
+import io.seata.rm.tcc.api.LocalTCC;
+import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
+
+@LocalTCC
+public interface BusinessService{
+
+
+ /**
+ * 执行资源检查及预留操作 开启防悬挂能力
+ */
+ @TwoPhaseBusinessAction(name = "prepareBuy", commitMethod = "commit", rollbackMethod = "rollback",useTCCFence = true)
+ public String prepareBuy(@BusinessActionContextParameter(paramName = "userId")String userId, @BusinessActionContextParameter(paramName = "commodityCode")String commodityCode,@BusinessActionContextParameter(paramName = "count") int count);
+
+ /**
+ * 全局事物进行提交
+ */
+ boolean commit(BusinessActionContext actionContext);
+
+ /**
+ * 全局事务进行回滚
+ */
+ boolean rollback(BusinessActionContext actionContext);
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/impl/BusinessServiceImpl.java b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..71547ca3c
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/java/com/seata/business/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,70 @@
+package com.seata.business.service.impl;
+
+import com.seata.business.client.AccountClient;
+import com.seata.business.client.InventoryClient;
+import com.seata.business.client.OrderClient;
+import com.seata.business.model.Order;
+import com.seata.business.service.BusinessService;
+import io.seata.core.context.RootContext;
+import io.seata.rm.tcc.api.BusinessActionContext;
+import io.seata.rm.tcc.api.BusinessActionContextUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class BusinessServiceImpl implements BusinessService {
+
+ @Autowired
+ private OrderClient orderClient;
+ @Autowired
+ private InventoryClient inventoryClient;
+ @Autowired
+ private AccountClient accountClient;
+
+
+
+ @Override
+ public String prepareBuy(String userId, String commodityCode, int count) {
+ log.info("开始TCC xid:" + RootContext.getXID());
+// 使用BusinessActionContextUtil工具类可将一阶段参数传递给二阶段,也可使用@BusinessActionContextParameter绑定参数,二者选其一
+// BusinessActionContextUtil.addContext("userId",userId);
+// BusinessActionContextUtil.addContext("commodityCode",commodityCode);
+// BusinessActionContextUtil.addContext("count",count);
+ //1.查询账户 预占扣款
+ int money = count * 1;
+ accountClient.occupy(userId,money);
+ //2.远程创建订单
+ Order order = new Order();
+ order.setUserId(userId);
+ order.setCommodityCode(commodityCode);
+ order.setCount(count);
+ order.setMoney(money);
+ orderClient.create(order);
+ //3.远程预占库存
+ inventoryClient.occupy(commodityCode,count);
+ return "success";
+ }
+
+ @Override
+ public boolean commit(BusinessActionContext actionContext) {
+ log.info("xid = " + actionContext.getXid() + "提交成功");
+ return true;
+ }
+
+ @Override
+ public boolean rollback(BusinessActionContext actionContext) {
+ // 获取下单时的提交参数
+ String userId = String.valueOf(actionContext.getActionContext("userId"));
+ int count = Integer.parseInt(String.valueOf(actionContext.getActionContext("count")));
+ String commodityCode = String.valueOf(actionContext.getActionContext("commodityCode"));
+ // 进行分支事务账户预占的金额和仓库预占的库存回滚
+ accountClient.rollBackAccount(userId,count);
+ inventoryClient.rollBackInventory(commodityCode,count);
+ log.info("xid = " + actionContext.getXid() + "进行回滚操作");
+ return true;
+ }
+
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/resources/bootstrap.yml b/tcc-sample/suspend-tcc-sample/business/src/main/resources/bootstrap.yml
new file mode 100644
index 000000000..0283acd75
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/resources/bootstrap.yml
@@ -0,0 +1,51 @@
+server:
+ port: 6750
+spring:
+ application:
+ name: business-service
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ password: root
+ url: jdbc:mysql://127.0.0.1:3306/seata_samples?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
+
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ register-enabled: true
+ namespace:
+ config:
+ server-addr: 127.0.0.1:8848
+ enabled: true
+ file-extension: yaml
+ namespace:
+
+seata:
+ enabled: true
+ application-id: ${spring.application.name}
+ # 事务群组(可以每个应用独立取名,也可以使用相同的名字),要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+ tx-service-group: ${spring.application.name}-tx-group
+ service:
+ vgroup-mapping:
+ business-service-tx-group: "default"
+ config:
+ type: nacos
+ # 需要和server在同一个注册中心下
+ nacos:
+ namespace:
+ serverAddr: 127.0.0.1:8848
+ # 需要server端(registry和config)、nacos配置client端(registry和config)保持一致
+ group: SEATA_GROUP
+ username: "nacos"
+ password: "nacos"
+ registry:
+ type: nacos
+ nacos:
+ # 需要和server端保持一致,即server在nacos中的名称,默认为seata-server
+ application: seata-server
+ server-addr: 127.0.0.1:8848
+ group: SEATA_GROUP
+ namespace:
+ username: "nacos"
+ password: "nacos"
diff --git a/tcc-sample/suspend-tcc-sample/business/src/main/resources/sql/tcc_fence_log.sql b/tcc-sample/suspend-tcc-sample/business/src/main/resources/sql/tcc_fence_log.sql
new file mode 100644
index 000000000..38919dd7e
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/business/src/main/resources/sql/tcc_fence_log.sql
@@ -0,0 +1,36 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : localhost
+ Source Server Type : MySQL
+ Source Server Version : 80028
+ Source Host : 127.0.0.1:3306
+ Source Schema : seata_samples
+
+ Target Server Type : MySQL
+ Target Server Version : 80028
+ File Encoding : 65001
+
+ Date: 20/08/2022 13:59:30
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for tcc_fence_log
+-- ----------------------------
+DROP TABLE IF EXISTS `tcc_fence_log`;
+CREATE TABLE `tcc_fence_log` (
+ `xid` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'global id',
+ `branch_id` bigint(0) NOT NULL COMMENT 'branch id',
+ `action_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'action name',
+ `status` tinyint(0) NOT NULL COMMENT 'status(tried:1;committed:2;rollbacked:3;suspended:4)',
+ `gmt_create` datetime(3) NOT NULL COMMENT 'create time',
+ `gmt_modified` datetime(3) NOT NULL COMMENT 'update time',
+ PRIMARY KEY (`xid`, `branch_id`) USING BTREE,
+ INDEX `idx_gmt_modified`(`gmt_modified`) USING BTREE,
+ INDEX `idx_status`(`status`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/tcc-sample/suspend-tcc-sample/inventory/pom.xml b/tcc-sample/suspend-tcc-sample/inventory/pom.xml
new file mode 100644
index 000000000..c8c6cd1a7
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/pom.xml
@@ -0,0 +1,91 @@
+
+
+
+ seata-springcloud-nacos-sample
+ io.seata
+ 1.1.0
+
+ 4.0.0
+ com.seata.inventory
+ inventory-service
+ 1.0.0-SNAPSHOT
+ inventory-service
+ 仓储服务
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-seata
+
+
+ io.seata
+ seata-spring-boot-starter
+
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.5.2
+
+
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ tk.mybatis
+ mapper
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.2.3
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/InventoryApplication.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/InventoryApplication.java
new file mode 100644
index 000000000..adfad30c6
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/InventoryApplication.java
@@ -0,0 +1,21 @@
+package com.seata.inventory;
+
+//
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import tk.mybatis.spring.annotation.MapperScan;
+
+@SpringBootApplication
+@MapperScan("com.seata.inventory.mapper")
+@EnableDiscoveryClient
+@EnableFeignClients
+public class InventoryApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(InventoryApplication.class, args);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/controller/InventoryController.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/controller/InventoryController.java
new file mode 100644
index 000000000..f81a1ca7e
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/controller/InventoryController.java
@@ -0,0 +1,23 @@
+package com.seata.inventory.controller;
+
+import com.seata.inventory.service.InventoryService;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class InventoryController {
+ @Autowired
+ private InventoryService inventoryService;
+
+ @GetMapping("inventory/occupy")
+ public void occupy(@Param("commodityCode") String commodityCode , @Param("count") int count) {
+ inventoryService.occupy(commodityCode,count);
+ }
+
+ @GetMapping("inventory/rollBackInventory")
+ public void rollBackInventory(@Param("commodityCode") String commodityCode , @Param("count") int count) {
+ inventoryService.rollBackInventory(commodityCode,count);
+ }
+}
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/mapper/InventoryMapper.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/mapper/InventoryMapper.java
new file mode 100644
index 000000000..f4b9edccd
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/mapper/InventoryMapper.java
@@ -0,0 +1,18 @@
+package com.seata.inventory.mapper;
+
+import com.seata.inventory.model.Inventory;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Repository;
+import tk.mybatis.mapper.common.Mapper;
+
+
+@Repository
+public interface InventoryMapper extends Mapper {
+
+ @Update("update inventory_tbl set count = count - #{count} where commodity_code = #{commodityCode}")
+ void occupy(@Param("commodityCode") String commodityCode , @Param("count") int count);
+
+ @Update("update inventory_tbl set count = count + #{count} where commodity_code = #{commodityCode}")
+ void rollBackInventory(@Param("commodityCode") String commodityCode , @Param("count") int count);
+}
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/model/Inventory.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/model/Inventory.java
new file mode 100644
index 000000000..51635196e
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/model/Inventory.java
@@ -0,0 +1,25 @@
+package com.seata.inventory.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Table(name = "inventory_tbl")
+@Data
+@Accessors(chain = true)
+public class Inventory {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ private String commodityCode;
+
+ private Integer count;
+
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/InventoryService.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/InventoryService.java
new file mode 100644
index 000000000..4832848e3
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/InventoryService.java
@@ -0,0 +1,8 @@
+package com.seata.inventory.service;
+
+public interface InventoryService {
+
+ void occupy(String commodityCode , int count);
+
+ void rollBackInventory(String commodityCode, int count);
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/impl/InventoryServiceImpl.java b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/impl/InventoryServiceImpl.java
new file mode 100644
index 000000000..f3c396860
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/java/com/seata/inventory/service/impl/InventoryServiceImpl.java
@@ -0,0 +1,28 @@
+package com.seata.inventory.service.impl;
+
+import com.seata.inventory.mapper.InventoryMapper;
+import com.seata.inventory.service.InventoryService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+
+@Slf4j
+@Service
+public class InventoryServiceImpl implements InventoryService {
+
+ @Autowired
+ private InventoryMapper inventoryMapper;
+
+
+ @Override
+ public void occupy(String commodityCode, int count) {
+ inventoryMapper.occupy(commodityCode,count);
+ }
+
+ @Override
+ public void rollBackInventory(String commodityCode, int count) {
+ inventoryMapper.rollBackInventory(commodityCode,count);
+ }
+}
diff --git a/tcc-sample/suspend-tcc-sample/inventory/src/main/resources/bootstrap.yml b/tcc-sample/suspend-tcc-sample/inventory/src/main/resources/bootstrap.yml
new file mode 100644
index 000000000..b4889fc47
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/inventory/src/main/resources/bootstrap.yml
@@ -0,0 +1,53 @@
+server:
+ port: 6780
+spring:
+ application:
+ name: inventory-service
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ password: root
+ url: jdbc:mysql://127.0.0.1:3306/seata_samples?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ register-enabled: true
+ namespace:
+ config:
+ server-addr: 127.0.0.1:8848
+ enabled: true
+ file-extension: yaml
+ namespace:
+
+seata:
+ enabled: true
+ application-id: ${spring.application.name}
+ # 事务群组(可以每个应用独立取名,也可以使用相同的名字),要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+ tx-service-group: ${spring.application.name}-tx-group
+ service:
+ vgroup-mapping:
+ inventory-service-tx-group: "default"
+ config:
+ type: nacos
+ # 需要和server在同一个注册中心下
+ nacos:
+ namespace:
+ serverAddr: 127.0.0.1:8848
+ # 需要server端(registry和config)、nacos配置client端(registry和config)保持一致
+ group: SEATA_GROUP
+ username: "nacos"
+ password: "nacos"
+ registry:
+ type: nacos
+ nacos:
+ # 需要和server端保持一致,即server在nacos中的名称,默认为seata-server
+ application: seata-server
+ server-addr: 127.0.0.1:8848
+ group: SEATA_GROUP
+ namespace:
+ username: "nacos"
+ password: "nacos"
+
+mybatis:
+ mapperLocations: classpath:mapper/*.xml
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/order/pom.xml b/tcc-sample/suspend-tcc-sample/order/pom.xml
new file mode 100644
index 000000000..bae0ceb03
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/pom.xml
@@ -0,0 +1,91 @@
+
+
+
+ seata-springcloud-nacos-sample
+ io.seata
+ 1.1.0
+
+ 4.0.0
+ com.seata.order
+ order-service
+ 1.0.0-SNAPSHOT
+ order-service
+ 订单服务
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-seata
+
+
+ io.seata
+ seata-spring-boot-starter
+
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.5.2
+
+
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ tk.mybatis
+ mapper
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.2.3
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/OrderApplication.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/OrderApplication.java
new file mode 100644
index 000000000..1cb0eb485
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/OrderApplication.java
@@ -0,0 +1,20 @@
+package com.seata.order;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import tk.mybatis.spring.annotation.MapperScan;
+
+@SpringBootApplication
+@MapperScan("com.seata.order.mapper")
+@EnableDiscoveryClient
+@EnableFeignClients
+public class OrderApplication {
+
+
+ public static void main(String[] args) {
+ SpringApplication.run(OrderApplication.class, args);
+ }
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/controller/OrderController.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/controller/OrderController.java
new file mode 100644
index 000000000..1b876ef47
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/controller/OrderController.java
@@ -0,0 +1,23 @@
+package com.seata.order.controller;
+
+
+import com.seata.order.model.Order;
+import com.seata.order.service.OrderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+
+@RestController
+public class OrderController {
+ @Autowired
+ private OrderService orderService;
+
+ @PostMapping("order/create")
+ public Boolean create(@RequestBody Order order){
+
+ return orderService.create(order);
+ }
+}
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/mapper/OrderMapper.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/mapper/OrderMapper.java
new file mode 100644
index 000000000..fc3a21ee6
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/mapper/OrderMapper.java
@@ -0,0 +1,12 @@
+package com.seata.order.mapper;
+
+
+import com.seata.order.model.Order;
+import org.springframework.stereotype.Repository;
+import tk.mybatis.mapper.common.Mapper;
+
+
+@Repository
+public interface OrderMapper extends Mapper {
+
+}
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/model/Order.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/model/Order.java
new file mode 100644
index 000000000..9200efc82
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/model/Order.java
@@ -0,0 +1,29 @@
+package com.seata.order.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Table(name = "order_tbl")
+@Data
+@Accessors(chain = true)
+public class Order {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ private String userId;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ private Integer money;
+
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/OrderService.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/OrderService.java
new file mode 100644
index 000000000..d85651465
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/OrderService.java
@@ -0,0 +1,8 @@
+package com.seata.order.service;
+
+import com.seata.order.model.Order;
+
+public interface OrderService {
+
+ boolean create(Order order);
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/impl/OrderServiceImpl.java b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..5d3e2632d
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/java/com/seata/order/service/impl/OrderServiceImpl.java
@@ -0,0 +1,27 @@
+package com.seata.order.service.impl;
+
+
+import com.seata.order.mapper.OrderMapper;
+import com.seata.order.model.Order;
+import com.seata.order.service.OrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+
+@Slf4j
+@Service
+public class OrderServiceImpl implements OrderService {
+
+ @Autowired
+ private OrderMapper orderMapper;
+
+ @Override
+ public boolean create(Order order) {
+ log.info("创建订单开始");
+ int index = orderMapper.insert(order);
+ log.info("创建订单结束");
+ return index > 0;
+ }
+}
diff --git a/tcc-sample/suspend-tcc-sample/order/src/main/resources/bootstrap.yml b/tcc-sample/suspend-tcc-sample/order/src/main/resources/bootstrap.yml
new file mode 100644
index 000000000..1337a8025
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/order/src/main/resources/bootstrap.yml
@@ -0,0 +1,53 @@
+server:
+ port: 6770
+spring:
+ application:
+ name: order-service
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ username: root
+ password: root
+ url: jdbc:mysql://127.0.0.1:3306/seata_samples?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
+ cloud:
+ nacos:
+ discovery:
+ server-addr: 127.0.0.1:8848
+ register-enabled: true
+ namespace:
+ config:
+ server-addr: 127.0.0.1:8848
+ enabled: true
+ file-extension: yaml
+ namespace:
+
+seata:
+ enabled: true
+ application-id: ${spring.application.name}
+ # 事务群组(可以每个应用独立取名,也可以使用相同的名字),要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应
+ tx-service-group: ${spring.application.name}-tx-group
+ service:
+ vgroup-mapping:
+ order-service-tx-group: "default"
+ config:
+ type: nacos
+ # 需要和server在同一个注册中心下
+ nacos:
+ namespace:
+ serverAddr: 127.0.0.1:8848
+ # 需要server端(registry和config)、nacos配置client端(registry和config)保持一致
+ group: SEATA_GROUP
+ username: "nacos"
+ password: "nacos"
+ registry:
+ type: nacos
+ nacos:
+ # 需要和server端保持一致,即server在nacos中的名称,默认为seata-server
+ application: seata-server
+ server-addr: 127.0.0.1:8848
+ group: SEATA_GROUP
+ namespace:
+ username: "nacos"
+ password: "nacos"
+
+mybatis:
+ mapperLocations: classpath:mapper/*.xml
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/pom.xml b/tcc-sample/suspend-tcc-sample/pom.xml
new file mode 100644
index 000000000..8ea659ab0
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/pom.xml
@@ -0,0 +1,66 @@
+
+
+ pom
+
+ inventory
+ order
+ account
+ business
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.3.2.RELEASE
+
+
+ 4.0.0
+
+ io.seata
+ seata-springcloud-nacos-sample
+ 1.1.0
+
+
+ 2.4.2.RELEASE
+ 1.8
+ 2.1.5
+ 4.1.5
+ 1.5.2
+
+
+
+
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+ ${mybatis.version}
+
+
+ tk.mybatis
+ mapper
+ ${tk-mapper.version}
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ Hoxton.SR9
+ pom
+ import
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2.2.1.RELEASE
+ pom
+ import
+
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/seata-server/pom.xml b/tcc-sample/suspend-tcc-sample/seata-server/pom.xml
new file mode 100644
index 000000000..7218f7d20
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/seata-server/pom.xml
@@ -0,0 +1,73 @@
+
+
+
+ io.seata
+ seata-springcloud-nacos-sample
+ 1.1.0
+
+ 4.0.0
+ com.seata.server
+ seata-server
+ 1.0.0-SNAPSHOT
+ seata-server
+ seata-server
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ io.seata
+ seata-server
+ 1.5.2
+
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+ 10.2.3
+
+
+
+
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/seata-server/src/main/java/com/sever/ServerApplication.java b/tcc-sample/suspend-tcc-sample/seata-server/src/main/java/com/sever/ServerApplication.java
new file mode 100644
index 000000000..4d869d5da
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/seata-server/src/main/java/com/sever/ServerApplication.java
@@ -0,0 +1,14 @@
+package com.sever;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+import java.io.IOException;
+
+@SpringBootApplication(scanBasePackages = {"io.seata"})
+public class ServerApplication {
+ public static void main(String[] args) throws IOException {
+ // run the spring-boot application
+ SpringApplication.run(ServerApplication.class, args);
+ }
+}
\ No newline at end of file
diff --git a/tcc-sample/suspend-tcc-sample/seata-server/src/main/resources/application.yml b/tcc-sample/suspend-tcc-sample/seata-server/src/main/resources/application.yml
new file mode 100644
index 000000000..98c06d233
--- /dev/null
+++ b/tcc-sample/suspend-tcc-sample/seata-server/src/main/resources/application.yml
@@ -0,0 +1,90 @@
+server:
+ port: 7091
+
+spring:
+ application:
+ name: seata-server
+
+logging:
+ config: classpath:logback-spring.xml
+ file:
+ path: ${user.home}/logs/seata
+ extend:
+ logstash-appender:
+ destination: 127.0.0.1:4560
+ kafka-appender:
+ bootstrap-servers: 127.0.0.1:9092
+ topic: logback_to_logstash
+
+console:
+ user:
+ username: seata
+ password: seata
+
+seata:
+ config:
+ # support: nacos, consul, apollo, zk, etcd3
+ type: nacos
+ nacos:
+ server-addr: 127.0.0.1:8848
+ namespace:
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #access-key: ""
+ #secret-key: ""
+ data-id: seataServer.properties
+ registry:
+ # support: nacos, eureka, redis, zk, consul, etcd3, sofa
+ type: nacos
+ preferred-networks: 30.240.*
+ nacos:
+ application: seata-server
+ server-addr: 127.0.0.1:8848
+ group: SEATA_GROUP
+ namespace:
+ cluster: default
+ username: nacos
+ password: nacos
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #access-key: ""
+ #secret-key: ""
+ server:
+ service-port: 8091
+ store:
+ # support: file 、 db 、 redis
+ mode: db
+ session:
+ mode: file
+ lock:
+ mode: file
+ file:
+ dir: sessionStore
+ max-branch-session-size: 16384
+ max-global-session-size: 512
+ file-write-buffer-cache-size: 16384
+ session-reload-read-size: 100
+ flush-disk-mode: async
+ db:
+ datasource: druids
+ db-type: mysql
+ driver-class-name: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/seata
+ user: root
+ password: root
+ min-conn: 5
+ max-conn: 100
+ global-table: global_table
+ branch-table: branch_table
+ lock-table: lock_table
+ distributed-lock-table: distributed_lock
+ query-limit: 100
+ max-wait: 5000
+# server:
+# service-port: 8091 #If not configured, the default is '${server.port} + 1000'
+ security:
+ secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
+ tokenValidityInMilliseconds: 1800000
+ ignore:
+ urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
\ No newline at end of file
diff --git a/tcc/transfer-tcc-sample/README.MD b/tcc-sample/transfer-tcc-sample/README.MD
similarity index 100%
rename from tcc/transfer-tcc-sample/README.MD
rename to tcc-sample/transfer-tcc-sample/README.MD
diff --git a/tcc/transfer-tcc-sample/pom.xml b/tcc-sample/transfer-tcc-sample/pom.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/pom.xml
rename to tcc-sample/transfer-tcc-sample/pom.xml
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/ApplicationKeeper.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/ApplicationKeeper.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/ApplicationKeeper.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/ApplicationKeeper.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java
similarity index 90%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java
index ca273f753..5b7ee9a8b 100644
--- a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java
+++ b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/FirstTccAction.java
@@ -29,13 +29,12 @@ public interface FirstTccAction {
/**
* 一阶段方法
*
- * @param businessActionContext
+ *
* @param accountNo
* @param amount
*/
@TwoPhaseBusinessAction(name = "firstTccAction", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepareMinus(BusinessActionContext businessActionContext,
- @BusinessActionContextParameter(paramName = "accountNo") String accountNo,
+ public boolean prepareMinus(@BusinessActionContextParameter(paramName = "accountNo") String accountNo,
@BusinessActionContextParameter(paramName = "amount") double amount);
/**
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java
similarity index 90%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java
index 473129a11..01bf763a4 100644
--- a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java
+++ b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/SecondTccAction.java
@@ -29,13 +29,12 @@ public interface SecondTccAction {
/**
* 一阶段方法
*
- * @param businessActionContext
+ *
* @param accountNo
* @param amount
*/
@TwoPhaseBusinessAction(name = "secondTccAction", commitMethod = "commit", rollbackMethod = "rollback")
- public boolean prepareAdd(BusinessActionContext businessActionContext,
- @BusinessActionContextParameter(paramName = "accountNo") String accountNo,
+ public boolean prepareAdd(@BusinessActionContextParameter(paramName = "accountNo") String accountNo,
@BusinessActionContextParameter(paramName = "amount") double amount);
/**
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java
similarity index 97%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java
index 9f4924437..776c8e386 100644
--- a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java
+++ b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/FirstTccActionImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.samples.tcc.transfer.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.transfer.action.FirstTccAction;
import io.seata.samples.tcc.transfer.dao.AccountDAO;
@@ -43,16 +44,16 @@ public class FirstTccActionImpl implements FirstTccAction {
/**
* 一阶段准备,冻结 转账资金
*
- * @param businessActionContext
+ *
* @param accountNo
* @param amount
* @return
*/
@Override
- public boolean prepareMinus(BusinessActionContext businessActionContext, final String accountNo,
+ public boolean prepareMinus(final String accountNo,
final double amount) {
//分布式事务ID
- final String xid = businessActionContext.getXid();
+ final String xid = RootContext.getXID();
return fromDsTransactionTemplate.execute(new TransactionCallback() {
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java
similarity index 96%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java
index 5247ec5bf..f87ae7ff6 100644
--- a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java
+++ b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/action/impl/SecondTccActionImpl.java
@@ -15,6 +15,7 @@
*/
package io.seata.samples.tcc.transfer.action.impl;
+import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.samples.tcc.transfer.action.SecondTccAction;
import io.seata.samples.tcc.transfer.dao.AccountDAO;
@@ -40,16 +41,16 @@ public class SecondTccActionImpl implements SecondTccAction {
/**
* 一阶段准备,转入资金 准备
*
- * @param businessActionContext
+ *
* @param accountNo
* @param amount
* @return
*/
@Override
- public boolean prepareAdd(final BusinessActionContext businessActionContext, final String accountNo,
+ public boolean prepareAdd(final String accountNo,
final double amount) {
//分布式事务ID
- final String xid = businessActionContext.getXid();
+ final String xid = RootContext.getXID();
return toDsTransactionTemplate.execute(new TransactionCallback() {
@@ -60,7 +61,7 @@ public Boolean doInTransaction(TransactionStatus status) {
Account account = toAccountDAO.getAccountForUpdate(accountNo);
if (account == null) {
System.out.println(
- "prepareAdd: 账户[" + accountNo + "]不存在, txId:" + businessActionContext.getXid());
+ "prepareAdd: 账户[" + accountNo + "]不存在, txId:" + RootContext.getXID());
return false;
}
//待转入资金作为 不可用金额
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/TransferService.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/TransferService.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/TransferService.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/TransferService.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java
similarity index 94%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java
index 42d52fd10..84fcb447b 100644
--- a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java
+++ b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/activity/impl/TransferServiceImpl.java
@@ -43,7 +43,7 @@ public class TransferServiceImpl implements TransferService {
@GlobalTransactional
public boolean transfer(final String from, final String to, final double amount) {
//扣钱参与者,一阶段执行
- boolean ret = firstTccAction.prepareMinus(null, from, amount);
+ boolean ret = firstTccAction.prepareMinus(from, amount);
if (!ret) {
//扣钱参与者,一阶段失败; 回滚本地事务和分布式事务
@@ -51,7 +51,7 @@ public boolean transfer(final String from, final String to, final double amount)
}
//加钱参与者,一阶段执行
- ret = secondTccAction.prepareAdd(null, to, amount);
+ ret = secondTccAction.prepareAdd(to, amount);
if (!ret) {
throw new RuntimeException("账号:[" + to + "] 预收款失败");
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/AccountDAO.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/AccountDAO.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/AccountDAO.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/AccountDAO.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/impl/AccountDAOImpl.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/impl/AccountDAOImpl.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/impl/AccountDAOImpl.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/dao/impl/AccountDAOImpl.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/domains/Account.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/domains/Account.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/domains/Account.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/domains/Account.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/env/TransferDataPrepares.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/env/TransferDataPrepares.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/env/TransferDataPrepares.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/env/TransferDataPrepares.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferApplication.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferApplication.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferApplication.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferApplication.java
diff --git a/tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferProviderStarter.java b/tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferProviderStarter.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferProviderStarter.java
rename to tcc-sample/transfer-tcc-sample/src/main/java/io/seata/samples/tcc/transfer/starter/TransferProviderStarter.java
diff --git a/tcc/transfer-tcc-sample/src/main/resources/db-bean/from-datasource-bean.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/db-bean/from-datasource-bean.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/db-bean/from-datasource-bean.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/db-bean/from-datasource-bean.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/db-bean/to-datasource-bean.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/db-bean/to-datasource-bean.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/db-bean/to-datasource-bean.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/db-bean/to-datasource-bean.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/file.conf b/tcc-sample/transfer-tcc-sample/src/main/resources/file.conf
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/file.conf
rename to tcc-sample/transfer-tcc-sample/src/main/resources/file.conf
diff --git a/tcc/transfer-tcc-sample/src/main/resources/registry.conf b/tcc-sample/transfer-tcc-sample/src/main/resources/registry.conf
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/registry.conf
rename to tcc-sample/transfer-tcc-sample/src/main/resources/registry.conf
diff --git a/tcc/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-provider.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-dubbo-reference.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/spring/seata-tcc.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-tcc.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/spring/seata-tcc.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/spring/seata-tcc.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/sqlmap/account.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/sqlmap/account.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/sqlmap/account.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/sqlmap/account.xml
diff --git a/tcc/transfer-tcc-sample/src/main/resources/sqlmap/sqlMapConfig.xml b/tcc-sample/transfer-tcc-sample/src/main/resources/sqlmap/sqlMapConfig.xml
similarity index 100%
rename from tcc/transfer-tcc-sample/src/main/resources/sqlmap/sqlMapConfig.xml
rename to tcc-sample/transfer-tcc-sample/src/main/resources/sqlmap/sqlMapConfig.xml
diff --git a/tcc/transfer-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java b/tcc-sample/transfer-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java
similarity index 100%
rename from tcc/transfer-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java
rename to tcc-sample/transfer-tcc-sample/src/test/java/io/seata/samples/tcc/SeataServerStarter.java