diff --git a/.gitignore b/.gitignore
index 8902b03dd..3c090b4cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,4 +61,5 @@ Thumbs.db
*/.idea/
*/.mvn/
+*/**/.mvn/
*/target/
diff --git a/README.md b/README.md
index 1f9e93dde..c7f8c5938 100644
--- a/README.md
+++ b/README.md
@@ -1,57 +1,34 @@
-
-
-# Seata Samples
-
-Samples for Seata. This project contains several sub-projects, each of which is an example of integration with other
-projects.
-
-[](https://travis-ci.org/seata/seata-samples)
-
-
-> Friendly note: because the project depends on too much, all Maven modules are commented out by default.
->
-> You can modify [`pom.xml`](https://github.com/seata/seata-samples/blob/master/pom.xml).
-
-## Related repository
-
-* [Seata](https://github.com/seata/seata) - The Seata core project
-
-## Sub-projects
-
-* [springcloud-seata-sharding-jdbc-mybatis-plus-samples](https://github.com/wilbur-ltf/seata-samples/tree/master/springcloud-seata-sharding-jdbc-mybatis-plus-samples)Easy to understand, high availability,Integration example of [Spring Cloud](https://github.com/spring-cloud),[Seata](https://github.com/seata/seata),[ShardingJdbc](https://github.com/apache/shardingsphere),[MyBatisPlus](https://github.com/baomidou/mybatis-plus).
-* [spring-cloud-alibaba-samples](https://github.com/seata/seata-samples/tree/master/spring-cloud-alibaba-samples) -
- Spring Cloud Alibaba + Nacos + Dubbo + OpenFeign + Sentinel + Seata
-* [dubbo](https://github.com/seata/seata-samples/tree/master/dubbo) - Integration example
- of [Seata](https://github.com/seata/seata) and [Apache Dubbo](https://github.com/apache/dubbo)
-* [springboot](https://github.com/seata/seata-samples/tree/master/springboot) - Integration example
- of [Seata](https://github.com/seata/seata) and [Spring Boot](https://github.com/spring-projects/spring-boot/)
-* [nacos](https://github.com/seata/seata-samples/tree/master/nacos) - Integration example
- of [Seata](https://github.com/alibaba/fescar)、 [Apache Dubbo](https://github.com/apache/dubbo)
- and [Alibaba Nacos](https://github.com/alibaba/nacos/)
-* [springboot-dubbo-seata](https://github.com/seata/seata-samples/tree/master/springboot-dubbo-seata) - Integration
- example of [Seata](https://github.com/seata/seata)、 [Apache Dubbo](https://github.com/apache/dubbo)
- and [Spring Boot](https://github.com/spring-projects/spring-boot/)
-* [nutzboot-dubbo-seata](https://github.com/seata/seata-samples/tree/master/nutzboot-dubbo-fescar) - Integration example
- of [Seata](https://github.com/seata/seata)、 [Apache Dubbo](https://github.com/apache/dubbo)
- and [NutzBoot](https://github.com/nutzam/nutzboot/)
-* [springcloud-jpa-seata](https://github.com/seata/seata-samples/tree/master/springcloud-jpa-seata) - Integration
- example of [Seata](https://github.com/Seata) and [Spring Cloud](https://github.com/spring-cloud) and JPA
-* [spring-boot-multiple-datasource](./multiple-datasource) - Integration example of [Seata](https://github.com/Seata)
- and [Spring Boot](https://github.com/spring-projects/spring-boot/) with multiple datasource and MyBatis
-* [springboot-mybatis](https://github.com/seata/seata-samples/tree/master/springboot-mybatis) - Integration example
- of [Seata](https://github.com/Seata) and [Spring Boot](https://github.com/spring-projects/spring-boot/)
- and [Mybatis](https://github.com/mybatis/mybatis-3)
-* [api](https://github.com/seata/seata-samples/tree/master/api) - Non-Spring environment uses api to build Seata
- distributed transactions
-* [spring-boot-multiple-datasource-mybatis-plus](./multiple-datasource-mybatis-plus) - Integration example
- of [Seata](https://github.com/Seata) and [Spring Boot](https://github.com/spring-projects/spring-boot/) with multiple
- datasource and [MyBatisPlus](https://github.com/baomidou/mybatis-plus)
-* [springcloud-nacos-seata](https://github.com/seata/seata-samples/tree/master/springcloud-nacos-seata) - Integration
- example of [Seata](https://github.com/Seata) and [Spring Cloud](https://github.com/spring-cloud)
- and [Alibaba Nacos](https://github.com/alibaba/nacos/)
-* [saga](https://github.com/seata/seata-samples/tree/master/saga) - Saga mode distributed transaction demo projects
-* [dubbo-multiple-datasource-mybatis-plus](https://github.com/seata/seata-samples/tree/master/dubbo-multiple-datasource-mybatis-plus) Integration example of [Seata](https://github.com/Seata) and [Spring Boot](https://github.com/spring-projects/spring-boot/) [Apache Dubbo](https://github.com/apache/dubbo) with [dynamic](https://github.com/baomidou/dynamic-datasource-spring-boot-starter) multiple datasource and [MyBatisPlus](https://github.com/baomidou/mybatis-plus) and [Alibaba Nacos](https://github.com/alibaba/nacos/)
-
-## Guide
-
-- [Quick integration with Spring Cloud](./doc/quick-integration-with-spring-cloud.md)
+# samples code specification
+
+## Directory Structure
+
+The first and second levels are more of a directory
+
+Top level: seata-samples
+
+Second layer: at-sample, tcc-sample, saga-sample, xa-sample
+
+Third floor, The third layer is the specific sample and the naming convention is as follows:
+
+## naming
+
+naming with framework: spring-nacos-seata, springboot-naocs-zk-seata ...
+
+## dependency
+
+pom: The dependencies of each sample should be independent and should not depend on the dependencies of the parent pom of seata samples.
+
+
+
+# samples transaction model
+https://seata.apache.org/docs/user/quickstart/
+
+## start sequence
+
+1、account
+
+2、storage
+
+3、order
+
+4、business
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
deleted file mode 100644
index f24eaee20..000000000
--- a/api/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- seata-samples
- io.seata
- 1.1.0
-
- 4.0.0
- seata-samples-api
- jar
- seata-samples-api ${project.version}
-
-
-
- io.seata
- seata-all
-
-
- com.alibaba
- druid
-
-
- mysql
- mysql-connector-java
- ${mysql-connector.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
-
\ No newline at end of file
diff --git a/api/src/main/java/io/seata/samples/api/Bussiness.java b/api/src/main/java/io/seata/samples/api/Bussiness.java
deleted file mode 100644
index b130ad9a9..000000000
--- a/api/src/main/java/io/seata/samples/api/Bussiness.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api;
-
-import java.sql.SQLException;
-import java.util.concurrent.TimeUnit;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.rm.RMClient;
-import io.seata.samples.api.service.AccountService;
-import io.seata.samples.api.service.OrderService;
-import io.seata.samples.api.service.StockService;
-import io.seata.samples.api.service.impl.AccountServiceImpl;
-import io.seata.samples.api.service.impl.OrderServiceImpl;
-import io.seata.samples.api.service.impl.StockServiceImpl;
-import io.seata.tm.TMClient;
-import io.seata.tm.api.GlobalTransaction;
-import io.seata.tm.api.GlobalTransactionContext;
-
-/**
- * The type Bussiness.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21 使用api 构建 单体应用多数据源分布式事务 非spring环境
- */
-public class Bussiness {
-
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- * @throws SQLException the sql exception
- * @throws TransactionException the transaction exception
- */
- public static void main(String[] args) throws SQLException, TransactionException, InterruptedException {
-
- String userId = "U100001";
- String commodityCode = "C00321";
- int commodityCount = 100;
- int money = 999;
- AccountService accountService = new AccountServiceImpl();
- StockService stockService = new StockServiceImpl();
- OrderService orderService = new OrderServiceImpl();
- orderService.setAccountService(accountService);
-
- //reset data
- accountService.reset(userId, String.valueOf(money));
- stockService.reset(commodityCode, String.valueOf(commodityCount));
- orderService.reset(null, null);
-
- //init seata; only once
- String applicationId = "api";
- String txServiceGroup = "my_test_tx_group";
- TMClient.init(applicationId, txServiceGroup);
- RMClient.init(applicationId, txServiceGroup);
-
- //trx
- GlobalTransaction tx = GlobalTransactionContext.getCurrentOrCreate();
- try {
- tx.begin(60000, "testBiz");
- System.out.println("begin trx, xid is " + tx.getXid());
-
- //biz operate 3 dataSources
- //set >=5 will be rollback(200*5>999) else will be commit
- int opCount = 5;
- stockService.deduct(commodityCode, opCount);
- orderService.create(userId, commodityCode, opCount);
-
- //check data if negative
- boolean needCommit = ((StockServiceImpl)stockService).validNegativeCheck("count", commodityCode)
- && ((AccountServiceImpl)accountService).validNegativeCheck("money", userId);
-
- //if data negative rollback else commit
- if (needCommit) {
- tx.commit();
- } else {
- System.out.println("rollback trx, cause: data negative, xid is " + tx.getXid());
- tx.rollback();
- }
- } catch (Exception exx) {
- System.out.println("rollback trx, cause: " + exx.getMessage() + " , xid is " + tx.getXid());
- tx.rollback();
- throw exx;
- }
- TimeUnit.SECONDS.sleep(10);
-
- }
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/AbstractDataCheck.java b/api/src/main/java/io/seata/samples/api/service/AbstractDataCheck.java
deleted file mode 100644
index 1f447bd04..000000000
--- a/api/src/main/java/io/seata/samples/api/service/AbstractDataCheck.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The type Abstract data check.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public abstract class AbstractDataCheck {
-
- /**
- * Valid negative check boolean.
- *
- * @param field the field
- * @param id the id
- * @return the boolean
- */
- public boolean validNegativeCheck(String field, String id) throws SQLException {
- return doNegativeCheck(field, id) >= 0;
- }
-
- /**
- * Do negative check int.
- *
- * @param field the field
- * @param id the id
- * @return the int
- * @throws SQLException the sql exception
- */
- public abstract int doNegativeCheck(String field, String id) throws SQLException;
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/AccountService.java b/api/src/main/java/io/seata/samples/api/service/AccountService.java
deleted file mode 100644
index 2a0cafa12..000000000
--- a/api/src/main/java/io/seata/samples/api/service/AccountService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Account service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public interface AccountService extends DataResetService {
- /**
- * Reduce.
- *
- * @param userId the user id
- * @param money the money
- * @throws SQLException the sql exception
- */
- void reduce(String userId, int money) throws SQLException;
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/DataResetService.java b/api/src/main/java/io/seata/samples/api/service/DataResetService.java
deleted file mode 100644
index decaf5f6c..000000000
--- a/api/src/main/java/io/seata/samples/api/service/DataResetService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Data reset service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public interface DataResetService {
- /**
- * Reset.
- *
- * @param key the key
- * @param value the value
- * @throws SQLException the sql exception
- */
- void reset(String key, String value) throws SQLException;
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/OrderService.java b/api/src/main/java/io/seata/samples/api/service/OrderService.java
deleted file mode 100644
index 2bdfd0af1..000000000
--- a/api/src/main/java/io/seata/samples/api/service/OrderService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Order service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public interface OrderService extends DataResetService {
- /**
- * Sets account service.
- *
- * @param accountService the account service
- */
- void setAccountService(AccountService accountService);
-
- /**
- * Create.
- *
- * @param userId the user id
- * @param commodityCode the commodity code
- * @param count the count
- * @throws SQLException the sql exception
- */
- void create(String userId, String commodityCode, Integer count) throws SQLException;
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/StockService.java b/api/src/main/java/io/seata/samples/api/service/StockService.java
deleted file mode 100644
index d2e04746e..000000000
--- a/api/src/main/java/io/seata/samples/api/service/StockService.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Stock service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public interface StockService extends DataResetService {
- /**
- * Deduct.
- *
- * @param commodityCode the commodity code
- * @param count the count
- * @throws SQLException the sql exception
- */
- void deduct(String commodityCode, int count) throws SQLException;
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/impl/AccountServiceImpl.java b/api/src/main/java/io/seata/samples/api/service/impl/AccountServiceImpl.java
deleted file mode 100644
index ff633e970..000000000
--- a/api/src/main/java/io/seata/samples/api/service/impl/AccountServiceImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service.impl;
-
-import java.sql.SQLException;
-
-import io.seata.samples.api.service.AbstractDataCheck;
-import io.seata.samples.api.service.AccountService;
-import io.seata.samples.api.utils.DataSourceUtil;
-
-/**
- * The type Account service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public class AccountServiceImpl extends AbstractDataCheck implements AccountService {
-
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "account";
-
- @Override
- public void reduce(String userId, int money) throws SQLException {
- String sql = "update account_tbl set money = money - " + money + " where user_id = '" + userId + "'";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- }
-
- @Override
- public int doNegativeCheck(String field, String id) throws SQLException {
- String checkSql = "select " + field + " from account_tbl where user_id='" + id + "'";
- String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
- return Integer.parseInt(result);
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from account_tbl where user_id = '" + key + "'";
- String insertSql = "insert into account_tbl(user_id, money) values ('" + key + "', " + value + ")";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- DataSourceUtil.executeUpdate(DB_KEY, insertSql);
- }
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/impl/OrderServiceImpl.java b/api/src/main/java/io/seata/samples/api/service/impl/OrderServiceImpl.java
deleted file mode 100644
index 164998b21..000000000
--- a/api/src/main/java/io/seata/samples/api/service/impl/OrderServiceImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service.impl;
-
-import java.sql.SQLException;
-
-import io.seata.samples.api.service.AccountService;
-import io.seata.samples.api.service.OrderService;
-import io.seata.samples.api.utils.DataSourceUtil;
-
-/**
- * The type Order service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public class OrderServiceImpl implements OrderService {
-
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "order";
- private AccountService accountService;
-
- @Override
- public void setAccountService(AccountService accountService) {
- this.accountService = accountService;
- }
-
- @Override
- public void create(String userId, String commodityCode, Integer count) throws SQLException {
- int money = count * 200;
- String sql = "insert into order_tbl (user_id, commodity_code, count, money) values ('" + userId + "','"
- + commodityCode + "'," + count + "," + money + ")";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- accountService.reduce(userId, money);
-
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from order_tbl";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- }
-}
diff --git a/api/src/main/java/io/seata/samples/api/service/impl/StockServiceImpl.java b/api/src/main/java/io/seata/samples/api/service/impl/StockServiceImpl.java
deleted file mode 100644
index 6c8c67fa6..000000000
--- a/api/src/main/java/io/seata/samples/api/service/impl/StockServiceImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.service.impl;
-
-import java.sql.SQLException;
-
-import io.seata.samples.api.service.AbstractDataCheck;
-import io.seata.samples.api.service.StockService;
-import io.seata.samples.api.utils.DataSourceUtil;
-
-/**
- * The type Stock service.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public class StockServiceImpl extends AbstractDataCheck implements StockService {
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "stock";
-
- @Override
- public void deduct(String commodityCode, int count) throws SQLException {
- String sql = "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode
- + "'";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from stock_tbl where commodity_code = '" + key + "'";
- String insertSql = "insert into stock_tbl(commodity_code, count) values ('" + key + "', " + value + ")";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- DataSourceUtil.executeUpdate(DB_KEY, insertSql);
- }
-
- @Override
- public int doNegativeCheck(String field, String id) throws SQLException {
- String checkSql = "select " + field + " from stock_tbl where commodity_code='" + id + "'";
- String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
- return Integer.parseInt(result);
- }
-}
diff --git a/api/src/main/java/io/seata/samples/api/utils/DataSourceUtil.java b/api/src/main/java/io/seata/samples/api/utils/DataSourceUtil.java
deleted file mode 100644
index fbc8295b5..000000000
--- a/api/src/main/java/io/seata/samples/api/utils/DataSourceUtil.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.utils;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.sql.DataSource;
-
-import com.alibaba.druid.pool.DruidDataSource;
-
-import io.seata.rm.datasource.DataSourceProxy;
-
-/**
- * The type Data source util.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public class DataSourceUtil {
-
- /**
- * The constant JDBC_PRO_PATH.
- */
- public static final String JDBC_PRO_PATH = "jdbc.properties";
- /**
- * The constant DATA_SOURCE_MAP.
- */
- public static final ConcurrentMap DATA_SOURCE_MAP = new ConcurrentHashMap<>();
-
- /**
- * Gets data source.
- *
- * @param name the name
- * @return the data source
- */
- public static DataSource getDataSource(String name) {
- String driverKey = "jdbc." + name + ".driver";
- String urlKey = "jdbc." + name + ".url";
- String userNameKey = "jdbc." + name + ".username";
- String pwdKey = "jdbc." + name + ".password";
- DataSource dataSource = new DruidDataSource();
- ((DruidDataSource)dataSource).setDriverClassName(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, driverKey));
- ((DruidDataSource)dataSource).setUrl(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, urlKey));
- ((DruidDataSource)dataSource).setUsername(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, userNameKey));
- ((DruidDataSource)dataSource).setPassword(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, pwdKey));
- return new DataSourceProxy(dataSource);
- }
-
- /**
- * Gets connection.
- *
- * @param name the name
- * @return the connection
- * @throws SQLException the sql exception
- */
- public static Connection getConnection(String name) throws SQLException {
- return DATA_SOURCE_MAP.computeIfAbsent(name, s -> getDataSource(name)).getConnection();
- }
-
- /**
- * Execute update int.
- *
- * @param name the name
- * @param sql the sql
- * @return the int
- * @throws SQLException the sql exception
- */
- public static int executeUpdate(String name, String sql) throws SQLException {
- Connection connection = null;
- Statement statement = null;
- int result = 0;
- try {
- connection = getConnection(name);
- statement = connection.createStatement();
- result = statement.executeUpdate(sql);
-
- } catch (SQLException exx) {
- //todo
- throw exx;
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException exx) {
- }
- }
- return result;
- }
-
- /**
- * Gets single result.
- *
- * @param name the name
- * @param sql the sql
- * @return the single result
- * @throws SQLException the sql exception
- */
- public static String getSingleResult(String name, String sql) throws SQLException {
- Connection connection = null;
- Statement statement = null;
- String result = null;
- try {
- connection = getConnection(name);
- statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(sql);
- resultSet.next();
- result = resultSet.getString(1);
- } catch (SQLException exx) {
- //todo
- throw exx;
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException exx) {
- }
- }
- return result;
- }
-}
diff --git a/api/src/main/java/io/seata/samples/api/utils/PropertiesUtil.java b/api/src/main/java/io/seata/samples/api/utils/PropertiesUtil.java
deleted file mode 100644
index 383bed6fb..000000000
--- a/api/src/main/java/io/seata/samples/api/utils/PropertiesUtil.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.api.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * The type Properties util.
- *
- * @author jimin.jm @alibaba-inc.com
- * @date 2019 /08/21
- */
-public class PropertiesUtil {
-
- /**
- * Gets propertie value.
- *
- * @param path the path
- * @param key the key
- * @return the propertie value
- */
- public static String getPropertieValue(String path, String key) {
- return getPropertieValue(path, key, null);
-
- }
-
- /**
- * Gets propertie value.
- *
- * @param path the path
- * @param key the key
- * @param defaultValue the default value
- * @return the propertie value
- */
- public static String getPropertieValue(String path, String key, String defaultValue) {
- Properties properties = new Properties();
- InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream(path);
- try {
- properties.load(in);
- } catch (IOException ignore) {
- }
- String value = properties.getProperty(key);
- return value == null ? defaultValue : value;
- }
-}
-
diff --git a/api/src/main/resources/all.sql b/api/src/main/resources/all.sql
deleted file mode 100644
index b6ae6fb9f..000000000
--- a/api/src/main/resources/all.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-CREATE TABLE `account_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `stock_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `commodity_code` (`commodity_code`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `order_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT '0',
- `money` int(11) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `undo_log`
-(
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/api/src/main/resources/file.conf b/api/src/main/resources/file.conf
deleted file mode 100644
index c960c460a..000000000
--- a/api/src/main/resources/file.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-service {
- #vgroup->rgroup
- vgroupMapping.my_test_tx_group = "default"
- #only support single node
- default.grouplist = "127.0.0.1:8091"
- #degrade current not support
- enableDegrade = false
- #disable
- disable = false
-}
diff --git a/api/src/main/resources/jdbc.properties b/api/src/main/resources/jdbc.properties
deleted file mode 100644
index 81563eda5..000000000
--- a/api/src/main/resources/jdbc.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-jdbc.account.url=jdbc:mysql://rm-2zetd9474ydd1g5955o.mysql.rds.aliyuncs.com:3306/fescar?useSSL=false&serverTimezone=UTC
-jdbc.account.username=workshop
-jdbc.account.password=Workshop123
-jdbc.account.driver=com.mysql.jdbc.Driver
-# stock db config
-jdbc.stock.url=jdbc:mysql://rm-2zetd9474ydd1g5955o.mysql.rds.aliyuncs.com:3306/fescar?useSSL=false&serverTimezone=UTC
-jdbc.stock.username=workshop
-jdbc.stock.password=Workshop123
-jdbc.stock.driver=com.mysql.jdbc.Driver
-# order db config
-jdbc.order.url=jdbc:mysql://rm-2zetd9474ydd1g5955o.mysql.rds.aliyuncs.com:3306/fescar?useSSL=false&serverTimezone=UTC
-jdbc.order.username=workshop
-jdbc.order.password=Workshop123
-jdbc.order.driver=com.mysql.jdbc.Driver
\ No newline at end of file
diff --git a/api/src/main/resources/registry.conf b/api/src/main/resources/registry.conf
deleted file mode 100644
index c640e3a63..000000000
--- a/api/src/main/resources/registry.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "file"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- cluster = "default"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = "0"
- password = ""
- cluster = "default"
- timeout = "0"
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
- type = "file"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- group = "SEATA_GROUP"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- apollo {
- app.id = "seata-server"
- apollo.meta = "http://192.168.1.204:8801"
- namespace = "application"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/at-sample/at-api/pom.xml b/at-sample/at-api/pom.xml
new file mode 100644
index 000000000..77cbdcd14
--- /dev/null
+++ b/at-sample/at-api/pom.xml
@@ -0,0 +1,79 @@
+
+
+
+ 4.0.0
+ org.apache.seata
+ at-api
+ 2.0.0
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+
+ io.seata
+ seata-all
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.13.5
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/BusinessService.java b/at-sample/at-api/src/main/java/org/apache/seata/api/BusinessService.java
new file mode 100644
index 000000000..e1e7cb566
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/BusinessService.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api;
+
+import io.seata.core.exception.TransactionException;
+import io.seata.core.rpc.netty.RmNettyRemotingClient;
+import io.seata.rm.RMClient;
+import io.seata.tm.TMClient;
+import io.seata.tm.api.GlobalTransaction;
+import io.seata.tm.api.GlobalTransactionContext;
+import org.apache.seata.api.service.OrderService;
+import org.apache.seata.api.service.impl.AccountServiceImpl;
+import org.apache.seata.api.service.impl.OrderServiceImpl;
+import org.apache.seata.api.service.impl.StorageServiceImpl;
+import org.springframework.util.ReflectionUtils;
+
+import java.lang.reflect.Method;
+import java.sql.SQLException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * The type Bussiness.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21 使用api 构建 单体应用多数据源分布式事务 非spring环境
+ */
+public class BusinessService {
+
+ /**
+ * The entry point of application.
+ *
+ * @param args the input arguments
+ * @throws SQLException the sql exception
+ * @throws TransactionException the transaction exception
+ * @throws InterruptedException the interrupted exception
+ */
+ public static void main(String[] args) throws SQLException, TransactionException, InterruptedException {
+ // init tm client and rm client, only once
+ String applicationId = "api";
+ String txServiceGroup = "my_test_tx_group";
+ TMClient.init(applicationId, txServiceGroup);
+ RMClient.init(applicationId, txServiceGroup);
+
+ RmNettyRemotingClient rmNettyRemotingClient = RmNettyRemotingClient.getInstance();
+ Class extends RmNettyRemotingClient> rmRemoteClass = rmNettyRemotingClient.getClass();
+ ReflectionUtils.doWithFields(rmRemoteClass, field -> {
+ if (field.getName().equals("clientChannelManager")) {
+ field.setAccessible(true);
+ //channelManger
+ Object o = field.get(rmNettyRemotingClient);
+ Method reconnect;
+ try {
+ reconnect = o.getClass().getDeclaredMethod("reconnect", String.class);
+ reconnect.setAccessible(true);
+ reconnect.invoke(o, "default_tx_group");
+ } catch (Exception e) {
+ throw new RuntimeException("reconnect failed!", e);
+ }
+ }
+ });
+
+ String userId = "U100001";
+ String commodityCode = "C00321";
+ int commodityCount = 100;
+ int money = 999;
+ AccountServiceImpl accountService = new AccountServiceImpl();
+ StorageServiceImpl stockService = new StorageServiceImpl();
+ OrderService orderService = new OrderServiceImpl();
+ orderService.setAccountService(accountService);
+
+ //reset data
+ accountService.reset(userId, String.valueOf(money));
+ stockService.reset(commodityCode, String.valueOf(commodityCount));
+ orderService.reset(null, null);
+
+ //trx
+ GlobalTransaction tx = GlobalTransactionContext.getCurrentOrCreate();
+ try {
+ tx.begin(60000, "testBiz");
+ System.out.println("begin trx, xid is " + tx.getXid());
+
+ //biz operate 3 dataSources
+ //set >=5 will be rollback(200*5>999) else will be commit
+ int opCount = 5;
+ stockService.deduct(commodityCode, opCount);
+ orderService.create(userId, commodityCode, opCount);
+
+ //check data if negative
+ boolean needCommit = stockService.validNegativeCheck("count", commodityCode)
+ && accountService.validNegativeCheck("money", userId);
+
+ //if data negative rollback else commit
+ if (needCommit) {
+ tx.commit();
+ } else {
+ System.out.println("rollback trx, cause: data negative, xid is " + tx.getXid());
+ tx.rollback();
+ }
+ } catch (Exception exx) {
+ System.out.println("rollback trx, cause: " + exx.getMessage() + " , xid is " + tx.getXid());
+ tx.rollback();
+ throw exx;
+ }
+ TimeUnit.SECONDS.sleep(10);
+
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/AbstractDataCheck.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/AbstractDataCheck.java
new file mode 100644
index 000000000..8d75609a5
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/AbstractDataCheck.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service;
+
+import java.sql.SQLException;
+
+/**
+ * The type Abstract data check.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public abstract class AbstractDataCheck {
+
+ /**
+ * Valid negative check boolean.
+ *
+ * @param field the field
+ * @param id the id
+ * @return the boolean
+ */
+ public boolean validNegativeCheck(String field, String id) throws SQLException {
+ return doNegativeCheck(field, id) >= 0;
+ }
+
+ /**
+ * Do negative check int.
+ *
+ * @param field the field
+ * @param id the id
+ * @return the int
+ * @throws SQLException the sql exception
+ */
+ public abstract int doNegativeCheck(String field, String id) throws SQLException;
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/AccountService.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/AccountService.java
new file mode 100644
index 000000000..6a03c2112
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/AccountService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service;
+
+import java.sql.SQLException;
+
+/**
+ * The interface Account service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public interface AccountService extends DataResetService {
+ /**
+ * Reduce.
+ *
+ * @param userId the user id
+ * @param money the money
+ * @throws SQLException the sql exception
+ */
+ void reduce(String userId, int money) throws SQLException;
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/DataResetService.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/DataResetService.java
new file mode 100644
index 000000000..afcf98ddf
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/DataResetService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service;
+
+import java.sql.SQLException;
+
+/**
+ * The interface Data reset service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public interface DataResetService {
+ /**
+ * Reset.
+ *
+ * @param key the key
+ * @param value the value
+ * @throws SQLException the sql exception
+ */
+ void reset(String key, String value) throws SQLException;
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/OrderService.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/OrderService.java
new file mode 100644
index 000000000..b1437d33f
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/OrderService.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service;
+
+import java.sql.SQLException;
+
+/**
+ * The interface Order service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public interface OrderService extends DataResetService {
+ /**
+ * Sets account service.
+ *
+ * @param accountService the account service
+ */
+ void setAccountService(AccountService accountService);
+
+ /**
+ * Create.
+ *
+ * @param userId the user id
+ * @param commodityCode the commodity code
+ * @param count the count
+ * @throws SQLException the sql exception
+ */
+ void create(String userId, String commodityCode, Integer count) throws SQLException;
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/StorageService.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/StorageService.java
new file mode 100644
index 000000000..5d7617e11
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/StorageService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service;
+
+import java.sql.SQLException;
+
+/**
+ * The interface Stock service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public interface StorageService extends DataResetService {
+ /**
+ * Deduct.
+ *
+ * @param commodityCode the commodity code
+ * @param count the count
+ * @throws SQLException the sql exception
+ */
+ void deduct(String commodityCode, int count) throws SQLException;
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/AccountServiceImpl.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..ce614fc78
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/AccountServiceImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service.impl;
+
+import org.apache.seata.api.service.AbstractDataCheck;
+import org.apache.seata.api.service.AccountService;
+import org.apache.seata.api.utils.DataSourceUtil;
+
+import java.sql.SQLException;
+
+
+/**
+ * The type Account service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public class AccountServiceImpl extends AbstractDataCheck implements AccountService {
+
+ /**
+ * The constant DB_KEY.
+ */
+ public static final String DB_KEY = "account";
+
+ @Override
+ public void reduce(String userId, int money) throws SQLException {
+ String sql = "update account_tbl set money = money - " + money + " where user_id = '" + userId + "'";
+ DataSourceUtil.executeUpdate(DB_KEY, sql);
+ }
+
+ @Override
+ public int doNegativeCheck(String field, String id) throws SQLException {
+ String checkSql = "select " + field + " from account_tbl where user_id='" + id + "'";
+ String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
+ return Integer.parseInt(result);
+ }
+
+ @Override
+ public void reset(String key, String value) throws SQLException {
+ String deleteSql = "delete from account_tbl where user_id = '" + key + "'";
+ String insertSql = "insert into account_tbl(user_id, money) values ('" + key + "', " + value + ")";
+ DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
+ DataSourceUtil.executeUpdate(DB_KEY, insertSql);
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/OrderServiceImpl.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..d66fce2cf
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/OrderServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service.impl;
+
+import org.apache.seata.api.service.AccountService;
+import org.apache.seata.api.service.OrderService;
+import org.apache.seata.api.utils.DataSourceUtil;
+
+import java.sql.SQLException;
+
+
+/**
+ * The type Order service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public class OrderServiceImpl implements OrderService {
+
+ /**
+ * The constant DB_KEY.
+ */
+ public static final String DB_KEY = "order";
+ private AccountService accountService;
+
+ @Override
+ public void setAccountService(AccountService accountService) {
+ this.accountService = accountService;
+ }
+
+ @Override
+ public void create(String userId, String commodityCode, Integer count) throws SQLException {
+ int money = count * 200;
+ String sql = "insert into order_tbl (user_id, commodity_code, count, money) values ('" + userId + "','"
+ + commodityCode + "'," + count + "," + money + ")";
+ DataSourceUtil.executeUpdate(DB_KEY, sql);
+ accountService.reduce(userId, money);
+
+ }
+
+ @Override
+ public void reset(String key, String value) throws SQLException {
+ String deleteSql = "delete from order_tbl";
+ DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/StorageServiceImpl.java b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..280038ef1
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/service/impl/StorageServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.service.impl;
+
+import org.apache.seata.api.service.AbstractDataCheck;
+import org.apache.seata.api.service.StorageService;
+import org.apache.seata.api.utils.DataSourceUtil;
+
+import java.sql.SQLException;
+
+
+
+/**
+ * The type Stock service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public class StorageServiceImpl extends AbstractDataCheck implements StorageService {
+ /**
+ * The constant DB_KEY.
+ */
+ public static final String DB_KEY = "stock";
+
+ @Override
+ public void deduct(String commodityCode, int count) throws SQLException {
+ String sql = "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode
+ + "'";
+ DataSourceUtil.executeUpdate(DB_KEY, sql);
+ }
+
+ @Override
+ public void reset(String key, String value) throws SQLException {
+ String deleteSql = "delete from stock_tbl where commodity_code = '" + key + "'";
+ String insertSql = "insert into stock_tbl(commodity_code, count) values ('" + key + "', " + value + ")";
+ DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
+ DataSourceUtil.executeUpdate(DB_KEY, insertSql);
+ }
+
+ @Override
+ public int doNegativeCheck(String field, String id) throws SQLException {
+ String checkSql = "select " + field + " from stock_tbl where commodity_code='" + id + "'";
+ String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
+ return Integer.parseInt(result);
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/utils/DataSourceUtil.java b/at-sample/at-api/src/main/java/org/apache/seata/api/utils/DataSourceUtil.java
new file mode 100644
index 000000000..6e4d647e3
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/utils/DataSourceUtil.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.utils;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import io.seata.rm.datasource.DataSourceProxy;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * The type Data source util.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public class DataSourceUtil {
+
+ /**
+ * The constant JDBC_PRO_PATH.
+ */
+ public static final String JDBC_PRO_PATH = "jdbc.properties";
+ /**
+ * The constant DATA_SOURCE_MAP.
+ */
+ public static final ConcurrentMap DATA_SOURCE_MAP = new ConcurrentHashMap<>();
+
+ /**
+ * Gets data source.
+ *
+ * @param name the name
+ * @return the data source
+ */
+ public static DataSource getDataSource(String name) {
+ String driverKey = "jdbc." + name + ".driver";
+ String urlKey = "jdbc." + name + ".url";
+ String userNameKey = "jdbc." + name + ".username";
+ String pwdKey = "jdbc." + name + ".password";
+ DruidDataSource dataSource = new DruidDataSource();
+ dataSource.setDriverClassName(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, driverKey));
+ dataSource.setUrl(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, urlKey));
+ dataSource.setUsername(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, userNameKey));
+ dataSource.setPassword(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, pwdKey));
+ return new DataSourceProxy(dataSource);
+ }
+
+ /**
+ * Gets connection.
+ *
+ * @param name the name
+ * @return the connection
+ * @throws SQLException the sql exception
+ */
+ public static Connection getConnection(String name) throws SQLException {
+ return DATA_SOURCE_MAP.computeIfAbsent(name, s -> getDataSource(name)).getConnection();
+ }
+
+ /**
+ * Execute update int.
+ *
+ * @param name the name
+ * @param sql the sql
+ * @return the int
+ * @throws SQLException the sql exception
+ */
+ public static int executeUpdate(String name, String sql) throws SQLException {
+ Connection connection = null;
+ Statement statement = null;
+ int result;
+ try {
+ connection = getConnection(name);
+ statement = connection.createStatement();
+ result = statement.executeUpdate(sql);
+
+ } finally {
+ try {
+ if (statement != null) {
+ statement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ } catch (SQLException ignore) {
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Gets single result.
+ *
+ * @param name the name
+ * @param sql the sql
+ * @return the single result
+ * @throws SQLException the sql exception
+ */
+ public static String getSingleResult(String name, String sql) throws SQLException {
+ Connection connection = null;
+ Statement statement = null;
+ String result;
+ try {
+ connection = getConnection(name);
+ statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(sql);
+ resultSet.next();
+ result = resultSet.getString(1);
+ } finally {
+ try {
+ if (statement != null) {
+ statement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ } catch (SQLException ignore) {
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/java/org/apache/seata/api/utils/PropertiesUtil.java b/at-sample/at-api/src/main/java/org/apache/seata/api/utils/PropertiesUtil.java
new file mode 100644
index 000000000..da78b71d6
--- /dev/null
+++ b/at-sample/at-api/src/main/java/org/apache/seata/api/utils/PropertiesUtil.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.api.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * The type Properties util.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ * @date 2019 /08/21
+ */
+public class PropertiesUtil {
+
+ /**
+ * Gets propertie value.
+ *
+ * @param path the path
+ * @param key the key
+ * @return the propertie value
+ */
+ public static String getPropertieValue(String path, String key) {
+ return getPropertieValue(path, key, null);
+
+ }
+
+ /**
+ * Gets propertie value.
+ *
+ * @param path the path
+ * @param key the key
+ * @param defaultValue the default value
+ * @return the propertie value
+ */
+ public static String getPropertieValue(String path, String key, String defaultValue) {
+ Properties properties = new Properties();
+ InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream(path);
+ try {
+ properties.load(in);
+ } catch (IOException ignore) {
+ }
+ String value = properties.getProperty(key);
+ return value == null ? defaultValue : value;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/resources/all.sql b/at-sample/at-api/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/at-api/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/resources/file.conf b/at-sample/at-api/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/at-api/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/at-api/src/main/resources/jdbc.properties b/at-sample/at-api/src/main/resources/jdbc.properties
new file mode 100644
index 000000000..060fd963e
--- /dev/null
+++ b/at-sample/at-api/src/main/resources/jdbc.properties
@@ -0,0 +1,14 @@
+jdbc.account.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+jdbc.account.username=root
+jdbc.account.password=123456
+jdbc.account.driver=com.mysql.jdbc.Driver
+# stock db config
+jdbc.stock.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+jdbc.stock.username=root
+jdbc.stock.password=123456
+jdbc.stock.driver=com.mysql.jdbc.Driver
+# order db config
+jdbc.order.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+jdbc.order.username=root
+jdbc.order.password=123456
+jdbc.order.driver=com.mysql.jdbc.Driver
\ No newline at end of file
diff --git a/at-sample/at-api/src/main/resources/registry.conf b/at-sample/at-api/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/at-api/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/pom.xml b/at-sample/spring-dubbo-seata/pom.xml
new file mode 100644
index 000000000..563e247fc
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/pom.xml
@@ -0,0 +1,104 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ spring-dubbo-seata
+ 2.0.0
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+
+ io.seata
+ seata-all
+ 2.0.0
+
+
+
+ org.springframework
+ spring-jdbc
+ 5.3.20
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.13.5
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+ org.apache.dubbo
+ dubbo
+ 3.1.2
+
+
+
+ org.apache.dubbo
+ dubbo-remoting-zookeeper-curator5
+ 3.1.2
+
+
+ org.apache.curator
+ curator-x-discovery
+ 5.1.0
+
+
+
+
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java
new file mode 100644
index 000000000..4a39311dd
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account;
+
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+
+@EnableAutoDataSourceProxy
+@EnableDubbo(scanBasePackages = {"org.apache.seata.account"})
+@ComponentScan(basePackages = {"org.apache.seata.account"})
+public class DubboAccountServiceStarter {
+
+ /**
+ * Enable PropertySource placeHolder
+ */
+ @Bean
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ new AnnotationConfigApplicationContext(DubboAccountServiceStarter.class);
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DataSourceConfiguration.java
new file mode 100644
index 000000000..038ceee82
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DataSourceConfiguration.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+/**
+ * DataSource Configuration
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DataSourceConfiguration {
+
+
+ @Value("${spring.datasource.account.driverClassName}")
+ private String driverClassName;
+ @Value("${spring.datasource.account.url}")
+ private String url;
+ @Value("${spring.datasource.account.username}")
+ private String userName;
+ @Value("${spring.datasource.account.password}")
+ private String password;
+
+ @Bean
+ public DataSource accountDataSource() {
+ DruidDataSource druidDataSource = new DruidDataSource();
+ druidDataSource.setUsername(userName);
+ druidDataSource.setPassword(password);
+ druidDataSource.setUrl(url);
+ druidDataSource.setDriverClassName(driverClassName);
+ return druidDataSource;
+ }
+
+ @Bean
+ public JdbcTemplate jdbcTemplate(@Qualifier("accountDataSource") DataSource dataSource) {
+ return new JdbcTemplate(dataSource);
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DubboConfiguration.java
new file mode 100644
index 000000000..e1039b756
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/DubboConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account.config;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * @author wangte
+ * Create At 2024/1/20
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DubboConfiguration {
+
+ @Value("${spring.account.application.name}")
+ private String applicationName;
+
+ @Bean
+ public ApplicationConfig applicationConfig() {
+ ApplicationConfig applicationConfig = new ApplicationConfig(applicationName);
+ applicationConfig.setQosEnable(false);
+ return applicationConfig;
+ }
+
+ @Bean
+ public RegistryConfig registryConfig() {
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setAddress("zookeeper://localhost:2181");
+ return registryConfig;
+ }
+
+ @Bean
+ public ProtocolConfig protocolConfig() {
+ ProtocolConfig protocolConfig = new ProtocolConfig();
+ protocolConfig.setName("dubbo");
+ protocolConfig.setPort(20881);
+ return protocolConfig;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/SeataConfiguration.java
new file mode 100644
index 000000000..ec448c5f3
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/config/SeataConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account.config;
+
+import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata Config
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class SeataConfiguration {
+
+ @Value("${spring.account.application.name}")
+ private String applicationName;
+
+ /**
+ * 注册一个StatViewServlet
+ *
+ * @return global transaction scanner
+ */
+ @Bean
+ public GlobalTransactionScanner globalTransactionScanner() {
+ return new GlobalTransactionScanner(applicationName, "my_test_tx_group");
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/AccountService.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/AccountService.java
new file mode 100644
index 000000000..3c297f44e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/AccountService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account.service;
+
+public interface AccountService {
+
+ /**
+ * 余额扣款
+ *
+ * @param userId 用户ID
+ * @param money 扣款金额
+ */
+ void debit(String userId, int money);
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/impl/AccountServiceImpl.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..7d4f8b365
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/account/service/impl/AccountServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.account.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.account.service.AccountService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.annotation.Resource;
+
+@DubboService
+public class AccountServiceImpl implements AccountService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void debit(String userId, int money) {
+ LOGGER.info("Account Service ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
+ userId);
+
+ jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", new Object[]{money, userId});
+ LOGGER.info("Account Service End ... ");
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java
new file mode 100644
index 000000000..cb7ec2383
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.business;
+
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.apache.seata.business.service.BusinessService;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+@EnableAutoDataSourceProxy
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.business"})
+public class DubboBusinessServiceTester {
+
+ /**
+ * Enable PropertySource placeHolder
+ */
+ @Bean
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(DubboBusinessServiceTester.class);
+
+ BusinessService businessService = annotationConfigApplicationContext.getBean(BusinessService.class);
+ Thread thread = new Thread(() -> businessService.purchase("U100001", "C00321", 2));
+ thread.start();
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/DubboConfiguration.java
new file mode 100644
index 000000000..2a7708d6d
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/DubboConfiguration.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.business.config;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * @author wangte
+ * Create At 2024/1/20
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DubboConfiguration {
+
+ @Value("${spring.business.application.name}")
+ private String applicationName;
+
+ @Bean
+ public ApplicationConfig applicationConfig() {
+ ApplicationConfig applicationConfig = new ApplicationConfig(applicationName);
+ applicationConfig.setQosEnable(false);
+ return applicationConfig;
+ }
+
+ @Bean
+ public RegistryConfig registryConfig() {
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setAddress("zookeeper://localhost:2181");
+ return registryConfig;
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/SeataConfiguration.java
new file mode 100644
index 000000000..31ee831c2
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/config/SeataConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.business.config;
+
+import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata Config
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class SeataConfiguration {
+
+ @Value("${spring.business.application.name}")
+ private String applicationName;
+
+ /**
+ * 注册一个StatViewServlet
+ *
+ * @return global transaction scanner
+ */
+ @Bean
+ public GlobalTransactionScanner globalTransactionScanner() {
+ return new GlobalTransactionScanner(applicationName, "my_test_tx_group");
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/BusinessService.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/BusinessService.java
new file mode 100644
index 000000000..e5e7e9734
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/BusinessService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.business.service;
+
+public interface BusinessService {
+
+ /**
+ * 用户订购商品
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void purchase(String userId, String commodityCode, int orderCount);
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/impl/BusinessServiceImpl.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..ad1d6302a
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/business/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.business.service.impl;
+
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.seata.business.service.BusinessService;
+import org.apache.seata.order.service.OrderService;
+import org.apache.seata.storage.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.Random;
+
+@Service
+public class BusinessServiceImpl implements BusinessService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
+
+ @DubboReference
+ private StorageService storageService;
+ @DubboReference
+ private OrderService orderService;
+ private final Random random = new Random();
+
+ @Override
+ @GlobalTransactional(timeoutMills = 300000, name = "spring-dubbo-tx")
+ public void purchase(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
+ storageService.deduct(commodityCode, orderCount);
+ // just test batch update
+ //stockService.batchDeduct(commodityCode, orderCount);
+ orderService.create(userId, commodityCode, orderCount);
+ if (random.nextBoolean()) {
+ throw new RuntimeException("random exception mock!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java
new file mode 100644
index 000000000..6e5d68e22
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order;
+
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+
+@EnableAutoDataSourceProxy
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.order"})
+public class DubboOrderServiceStarter {
+
+ /**
+ * Enable PropertySource placeHolder
+ */
+ @Bean
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ new AnnotationConfigApplicationContext(DubboOrderServiceStarter.class);
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DataSourceConfiguration.java
new file mode 100644
index 000000000..712324cff
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DataSourceConfiguration.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+/**
+ * DataSource Configuration
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DataSourceConfiguration {
+
+
+ @Value("${spring.datasource.order.driverClassName}")
+ private String driverClassName;
+ @Value("${spring.datasource.order.url}")
+ private String url;
+ @Value("${spring.datasource.order.username}")
+ private String userName;
+ @Value("${spring.datasource.order.password}")
+ private String password;
+
+ @Bean
+ public DataSource orderDataSource() {
+ DruidDataSource druidDataSource = new DruidDataSource();
+ druidDataSource.setUsername(userName);
+ druidDataSource.setPassword(password);
+ druidDataSource.setUrl(url);
+ druidDataSource.setDriverClassName(driverClassName);
+ return druidDataSource;
+ }
+
+ @Bean
+ public JdbcTemplate jdbcTemplate(@Qualifier("orderDataSource") DataSource dataSource) {
+ return new JdbcTemplate(dataSource);
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DubboConfiguration.java
new file mode 100644
index 000000000..440ea161d
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/DubboConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order.config;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * @author wangte
+ * Create At 2024/1/20
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DubboConfiguration {
+
+ @Value("${spring.order.application.name}")
+ private String applicationName;
+
+
+ @Bean
+ public ApplicationConfig applicationConfig() {
+ ApplicationConfig applicationConfig = new ApplicationConfig(applicationName);
+ applicationConfig.setQosEnable(false);
+ return applicationConfig;
+ }
+ @Bean
+ public RegistryConfig registryConfig() {
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setAddress("zookeeper://localhost:2181");
+ return registryConfig;
+ }
+
+ @Bean
+ public ProtocolConfig protocolConfig() {
+ ProtocolConfig protocolConfig = new ProtocolConfig();
+ protocolConfig.setName("dubbo");
+ protocolConfig.setPort(20883);
+ return protocolConfig;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/SeataConfiguration.java
new file mode 100644
index 000000000..77ac8004a
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/config/SeataConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order.config;
+
+import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata Config
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class SeataConfiguration {
+
+ @Value("${spring.order.application.name}")
+ private String applicationName;
+
+ /**
+ * 注册一个StatViewServlet
+ *
+ * @return global transaction scanner
+ */
+ @Bean
+ public GlobalTransactionScanner globalTransactionScanner() {
+ return new GlobalTransactionScanner(applicationName, "my_test_tx_group");
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/OrderService.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/OrderService.java
new file mode 100644
index 000000000..8afe45deb
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/OrderService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order.service;
+
+public interface OrderService {
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void create(String userId, String commodityCode, int orderCount);
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/impl/OrderServiceImpl.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..0abef9006
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/order/service/impl/OrderServiceImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.order.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.account.service.AccountService;
+import org.apache.seata.order.service.OrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+
+import javax.annotation.Resource;
+import java.sql.PreparedStatement;
+import java.util.Objects;
+
+@DubboService
+public class OrderServiceImpl implements OrderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @DubboReference
+ private AccountService accountService;
+
+ @Override
+ public void create(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
+
+ // 计算订单金额
+ int orderMoney = calculate(commodityCode, orderCount);
+
+ // 从账户余额扣款
+ accountService.debit(userId, orderMoney);
+
+ LOGGER.info(
+ "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
+ userId, commodityCode, orderCount, orderMoney);
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+ jdbcTemplate.update(con -> {
+ PreparedStatement pst = con.prepareStatement(
+ "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
+ PreparedStatement.RETURN_GENERATED_KEYS);
+ pst.setObject(1, userId);
+ pst.setObject(2, commodityCode);
+ pst.setObject(3, orderCount);
+ pst.setObject(4, orderMoney);
+ return pst;
+ }, keyHolder);
+
+
+ LOGGER.info("Order Service End ... Created " + Objects.requireNonNull(keyHolder.getKey()).longValue());
+ }
+
+ private int calculate(String commodityId, int orderCount) {
+ return 200 * orderCount;
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java
new file mode 100644
index 000000000..1090841f5
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage;
+
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+
+@EnableAutoDataSourceProxy
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.storage"})
+public class DubboStorageServiceStarter {
+
+ /**
+ * Enable PropertySource placeHolder
+ */
+ @Bean
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public static void main(String[] args) throws InterruptedException {
+ new AnnotationConfigApplicationContext(DubboStorageServiceStarter.class);
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DataSourceConfiguration.java
new file mode 100644
index 000000000..58a4a8a72
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DataSourceConfiguration.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+/**
+ * DataSource Configuration
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DataSourceConfiguration {
+
+
+ @Value("${spring.datasource.stock.driverClassName}")
+ private String driverClassName;
+ @Value("${spring.datasource.stock.url}")
+ private String url;
+ @Value("${spring.datasource.stock.username}")
+ private String userName;
+ @Value("${spring.datasource.stock.password}")
+ private String password;
+
+ @Bean
+ public DataSource storageDataSource() {
+ DruidDataSource druidDataSource = new DruidDataSource();
+ druidDataSource.setUsername(userName);
+ druidDataSource.setPassword(password);
+ druidDataSource.setUrl(url);
+ druidDataSource.setDriverClassName(driverClassName);
+ return druidDataSource;
+ }
+
+ @Bean
+ public JdbcTemplate jdbcTemplate(@Qualifier("storageDataSource") DataSource dataSource) {
+ return new JdbcTemplate(dataSource);
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java
new file mode 100644
index 000000000..e2a6e13c0
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage.config;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * @author wangte
+ * Create At 2024/1/20
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DubboConfiguration {
+
+ @Value("${spring.storage.application.name}")
+ private String applicationName;
+
+ @Bean
+ public ApplicationConfig applicationConfig() {
+ ApplicationConfig applicationConfig = new ApplicationConfig(applicationName);
+ applicationConfig.setQosEnable(false);
+ return applicationConfig;
+ }
+
+ @Bean
+ public RegistryConfig registryConfig() {
+ RegistryConfig registryConfig = new RegistryConfig();
+ registryConfig.setAddress("zookeeper://localhost:2181");
+ return registryConfig;
+ }
+
+ @Bean
+ public ProtocolConfig protocolConfig() {
+ ProtocolConfig protocolConfig = new ProtocolConfig();
+ protocolConfig.setName("dubbo");
+ protocolConfig.setPort(20882);
+ return protocolConfig;
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/SeataConfiguration.java
new file mode 100644
index 000000000..e624111a9
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/config/SeataConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage.config;
+
+import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata Config
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class SeataConfiguration {
+
+ @Value("${spring.storage.application.name}")
+ private String applicationName;
+
+ /**
+ * 注册一个StatViewServlet
+ *
+ * @return global transaction scanner
+ */
+ @Bean
+ public GlobalTransactionScanner globalTransactionScanner() {
+ return new GlobalTransactionScanner(applicationName, "my_test_tx_group");
+ }
+
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/StorageService.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/StorageService.java
new file mode 100644
index 000000000..1358830e8
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/StorageService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage.service;
+
+public interface StorageService {
+
+ /**
+ * 扣减库存
+ *
+ * @param commodityCode 商品编号
+ * @param count 扣减数量
+ */
+ void deduct(String commodityCode, int count);
+
+ /**
+ * 批量扣减
+ *
+ * @param commodityCode
+ * @param count
+ */
+ void batchDeduct(String commodityCode, int count);
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/impl/StorageServiceImpl.java b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..fca6ae8cb
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/java/org/apache/seata/storage/service/impl/StorageServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.storage.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.storage.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.annotation.Resource;
+
+@DubboService
+public class StorageServiceImpl implements StorageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void deduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
+ new Object[]{count, commodityCode});
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+ @Override
+ public void batchDeduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.batchUpdate(
+ "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'",
+ "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'");
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/resources/all.sql b/at-sample/spring-dubbo-seata/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/src/main/resources/application.properties
new file mode 100644
index 000000000..b8d7fc9f0
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+spring.account.application.name=account-service
+spring.storage.application.name=storage-service
+spring.order.application.name=order-service
+spring.business.application.name=business-service
+spring.datasource.account.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.account.username=root
+spring.datasource.account.password=123456
+spring.datasource.account.driverClassName=com.mysql.jdbc.Driver
+# stock db config
+spring.datasource.stock.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.stock.username=root
+spring.datasource.stock.password=123456
+spring.datasource.stock.driverClassName=com.mysql.jdbc.Driver
+# order db config
+spring.datasource.order.url=jdbc:mysql://127.0.0.1:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.order.username=root
+spring.datasource.order.password=123456
+spring.datasource.order.driverClassName=com.mysql.jdbc.Driver
diff --git a/at-sample/spring-dubbo-seata/src/main/resources/file.conf b/at-sample/spring-dubbo-seata/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/src/main/resources/registry.conf b/at-sample/spring-dubbo-seata/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/spring-seata/pom.xml b/at-sample/spring-seata/pom.xml
new file mode 100644
index 000000000..e5ad7d916
--- /dev/null
+++ b/at-sample/spring-seata/pom.xml
@@ -0,0 +1,86 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ spring-seata
+ 2.0.0
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+
+ io.seata
+ seata-all
+ 2.0.0
+
+
+
+ org.springframework
+ spring-jdbc
+ 5.3.20
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.13.5
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
\ No newline at end of file
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java b/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
new file mode 100644
index 000000000..9729e4abd
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.seata.service.BusinessService;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+/**
+ * @author wangte
+ * Create At 2024/1/20
+ */
+@ComponentScan
+@Configuration
+@EnableAutoDataSourceProxy
+public class BusinessServiceTester {
+
+ /**
+ * Enable PropertySource placeHolder
+ */
+ @Bean
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public static void main(String[] args) throws Exception {
+ AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(BusinessServiceTester.class);
+
+ BusinessService businessService = annotationConfigApplicationContext.getBean(BusinessService.class);
+
+ Thread thread = new Thread(() -> businessService.purchase("U100001", "C00321", 2));
+ thread.start();
+ thread.join();
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/config/DataSourceConfiguration.java b/at-sample/spring-seata/src/main/java/org/apache/seata/config/DataSourceConfiguration.java
new file mode 100644
index 000000000..7d6687c4c
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/config/DataSourceConfiguration.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.provider.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+
+/**
+ * DataSource Configuration
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class DataSourceConfiguration {
+
+ @Value("${spring.datasource.driverClassName}")
+ private String driverClassName;
+ @Value("${spring.datasource.url}")
+ private String url;
+ @Value("${spring.datasource.username}")
+ private String userName;
+ @Value("${spring.datasource.password}")
+ private String password;
+
+ @Bean
+ public DataSource dataSource() {
+ DruidDataSource druidDataSource = new DruidDataSource();
+ druidDataSource.setUsername(userName);
+ druidDataSource.setPassword(password);
+ druidDataSource.setUrl(url);
+ druidDataSource.setDriverClassName(driverClassName);
+ return druidDataSource;
+ }
+
+ @Bean
+ public JdbcTemplate jdbcTemplate(DataSource dataSource) {
+ return new JdbcTemplate(dataSource);
+ }
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/config/SeataConfiguration.java b/at-sample/spring-seata/src/main/java/org/apache/seata/config/SeataConfiguration.java
new file mode 100644
index 000000000..029f876ae
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/config/SeataConfiguration.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.provider.config;
+
+import io.seata.spring.annotation.GlobalTransactionScanner;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * Seata Config
+ */
+@Configuration
+@PropertySource("classpath:application.properties")
+public class SeataConfiguration {
+
+ @Value("${spring.application.name}")
+ private String applicationId;
+
+ /**
+ * 注册一个StatViewServlet
+ *
+ * @return global transaction scanner
+ */
+ @Bean
+ public GlobalTransactionScanner globalTransactionScanner() {
+ return new GlobalTransactionScanner(applicationId, "my_test_tx_group");
+ }
+
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/AccountService.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/AccountService.java
new file mode 100644
index 000000000..2e8a75daa
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/AccountService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Account service.
+ */
+public interface AccountService {
+
+ /**
+ * 余额扣款
+ *
+ * @param userId 用户ID
+ * @param money 扣款金额
+ */
+ void debit(String userId, int money);
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/BusinessService.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/BusinessService.java
new file mode 100644
index 000000000..c6f16f415
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/BusinessService.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Business service.
+ */
+public interface BusinessService {
+
+ /**
+ * 用户订购商品
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void purchase(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/OrderService.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/OrderService.java
new file mode 100644
index 000000000..a360ca920
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/OrderService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+
+/**
+ * The interface Order service.
+ */
+public interface OrderService {
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void create(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/StorageService.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/StorageService.java
new file mode 100644
index 000000000..0f68fad94
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/StorageService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Stock service.
+ */
+public interface StorageService {
+
+ /**
+ * 扣减库存
+ *
+ * @param commodityCode 商品编号
+ * @param count 扣减数量
+ */
+ void deduct(String commodityCode, int count);
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..ab3482aeb
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.AccountService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Account service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class AccountServiceImpl implements AccountService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void debit(String userId, int money) {
+ LOGGER.info("Account Service ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
+ userId);
+
+ jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", money, userId);
+ LOGGER.info("Account Service End ... ");
+ }
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..a18e5aa88
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
+
+import org.apache.seata.service.BusinessService;
+import org.apache.seata.service.OrderService;
+import org.apache.seata.service.StorageService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Random;
+
+/**
+ * The type Business service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class BusinessServiceImpl implements BusinessService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
+
+ @Resource
+ private StorageService storageService;
+ @Resource
+ private OrderService orderService;
+ private final Random random = new Random();
+
+ @Override
+ @GlobalTransactional(timeoutMills = 300000, name = "spring-seata-tx")
+ public void purchase(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
+ storageService.deduct(commodityCode, orderCount);
+ orderService.create(userId, commodityCode, orderCount);
+ if (random.nextBoolean()) {
+ throw new RuntimeException("random exception mock!");
+ }
+ }
+
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..7aede43d7
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.AccountService;
+import org.apache.seata.service.OrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.PreparedStatement;
+import java.util.Objects;
+
+/**
+ * The type Order service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class OrderServiceImpl implements OrderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
+
+ @Resource
+ private AccountService accountService;
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void create(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
+
+ // 计算订单金额
+ int orderMoney = calculate(commodityCode, orderCount);
+
+ // 从账户余额扣款
+ accountService.debit(userId, orderMoney);
+
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+
+ LOGGER.info(
+ "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
+ userId, commodityCode, orderCount, orderMoney);
+
+ jdbcTemplate.update(con -> {
+ PreparedStatement pst = con.prepareStatement(
+ "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
+ PreparedStatement.RETURN_GENERATED_KEYS);
+ pst.setObject(1, userId);
+ pst.setObject(2, commodityCode);
+ pst.setObject(3, orderCount);
+ pst.setObject(4, orderMoney);
+ return pst;
+ }, keyHolder);
+
+
+ LOGGER.info("Order Service End ... Created " + Objects.requireNonNull(keyHolder.getKey()).longValue());
+ }
+
+ private int calculate(String commodityId, int orderCount) {
+ return 200 * orderCount;
+ }
+
+}
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..8ee0cc42d
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2021 Seata.io Group.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Stock service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class StorageServiceImpl implements StorageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void deduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
+ new Object[]{count, commodityCode});
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+}
diff --git a/at-sample/spring-seata/src/main/resources/all.sql b/at-sample/spring-seata/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/spring-seata/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/spring-seata/src/main/resources/application.properties b/at-sample/spring-seata/src/main/resources/application.properties
new file mode 100644
index 000000000..7aea7ea1f
--- /dev/null
+++ b/at-sample/spring-seata/src/main/resources/application.properties
@@ -0,0 +1,5 @@
+spring.application.name=spring-seata
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
\ No newline at end of file
diff --git a/at-sample/spring-seata/src/main/resources/file.conf b/at-sample/spring-seata/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/spring-seata/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/spring-seata/src/main/resources/registry.conf b/at-sample/spring-seata/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/spring-seata/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/pom.xml b/at-sample/springboot-dubbo-seata/pom.xml
new file mode 100644
index 000000000..a5987d339
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.0
+
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+ springboot-dubbo-seata
+ springboot-dubbo-seata
+ pom
+
+
+ springboot-dubbo-seata-common
+ springboot-dubbo-seata-storage
+ springboot-dubbo-seata-account
+ springboot-dubbo-seata-order
+ springboot-dubbo-seata-business
+
+
+
+ 8
+
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml
new file mode 100644
index 000000000..0c303112e
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml
@@ -0,0 +1,123 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+
+ springboot-dubbo-seata-account
+ 2.0.0
+ springboot-dubbo-seata-account
+ springboot-dubbo-seata-account
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+
+ org.apache.dubbo
+ dubbo-spring-boot-starter
+ 3.1.2
+
+
+ org.apache.dubbo
+ dubbo-remoting-zookeeper-curator5
+ 3.1.2
+
+
+ org.apache.curator
+ curator-x-discovery
+ 5.1.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+ org.apache.seata
+ springboot-dubbo-seata-common
+ 2.0.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/SpringbootDubboSeataAccountApplication.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/SpringbootDubboSeataAccountApplication.java
new file mode 100644
index 000000000..27ad4bb66
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/SpringbootDubboSeataAccountApplication.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootDubboSeataAccountApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringbootDubboSeataAccountApplication.class, args);
+ }
+
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..d11c447da
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.service.AccountService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.annotation.Resource;
+
+@DubboService
+public class AccountServiceImpl implements AccountService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void debit(String userId, int money) {
+ LOGGER.info("Account Service ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
+ userId);
+
+ jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", new Object[]{money, userId});
+ LOGGER.info("Account Service End ... ");
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/all.sql b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/application.properties b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/application.properties
new file mode 100644
index 000000000..c89f20f95
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+spring.application.name=springboot-dubbo-seata-account
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
+seata.application-id=springboot-dubbo-seata-account
+seata.tx-service-group=my_test_tx_group
+dubbo.scan.base-packages=org.apache.seata
+dubbo.application.qos-enable=false
+dubbo.registry.address=zookeeper://localhost:2181
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=28801
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/file.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/registry.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml
new file mode 100644
index 000000000..5e9168528
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml
@@ -0,0 +1,111 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+
+ springboot-dubbo-seata-business
+ 2.0.0
+ springboot-dubbo-seata-business
+ springboot-dubbo-seata-business
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ org.apache.dubbo
+ dubbo-spring-boot-starter
+ 3.1.2
+
+
+ org.apache.dubbo
+ dubbo-remoting-zookeeper-curator5
+ 3.1.2
+
+
+ org.apache.curator
+ curator-x-discovery
+ 5.1.0
+
+
+
+ org.apache.seata
+ springboot-dubbo-seata-common
+ 2.0.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/SpringbootDubboSeataBusinessApplication.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/SpringbootDubboSeataBusinessApplication.java
new file mode 100644
index 000000000..22cd54d86
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/SpringbootDubboSeataBusinessApplication.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import org.apache.seata.service.BusinessService;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootDubboSeataBusinessApplication implements BeanFactoryAware {
+
+ private static BeanFactory BEAN_FACTORY;
+
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(SpringbootDubboSeataBusinessApplication.class, args);
+
+ BusinessService businessService = BEAN_FACTORY.getBean(BusinessService.class);
+
+ businessService.purchase("U100001", "C00321", 2);
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ BEAN_FACTORY = beanFactory;
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/BusinessService.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/BusinessService.java
new file mode 100644
index 000000000..c6f16f415
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/BusinessService.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Business service.
+ */
+public interface BusinessService {
+
+ /**
+ * 用户订购商品
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void purchase(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..e6e374099
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.seata.service.BusinessService;
+import org.apache.seata.service.OrderService;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.util.Random;
+
+@Service
+public class BusinessServiceImpl implements BusinessService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
+
+ @DubboReference
+ private StorageService storageService;
+ @DubboReference
+ private OrderService orderService;
+ private final Random random = new Random();
+
+ @Override
+ @GlobalTransactional(timeoutMills = 300000, name = "spring-dubbo-tx")
+ public void purchase(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
+ storageService.deduct(commodityCode, orderCount);
+ // just test batch update
+ //stockService.batchDeduct(commodityCode, orderCount);
+ orderService.create(userId, commodityCode, orderCount);
+ if (random.nextBoolean()) {
+ throw new RuntimeException("random exception mock!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/all.sql b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/application.properties b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/application.properties
new file mode 100644
index 000000000..4dc07526d
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+spring.application.name=springboot-dubbo-seata-business
+seata.application-id=springboot-dubbo-seata-business
+seata.tx-service-group=my_test_tx_group
+dubbo.application.qos-enable=false
+dubbo.scan.base-packages=org.apache.seata
+dubbo.registry.address=zookeeper://localhost:2181
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20883
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/file.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/registry.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml
new file mode 100644
index 000000000..29392592a
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+
+ springboot-dubbo-seata-common
+ 2.0.0
+ springboot-dubbo-seata-common
+ springboot-dubbo-seata-common
+ jar
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java
new file mode 100644
index 000000000..6ae18eea8
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+public interface AccountService {
+
+ /**
+ * 余额扣款
+ *
+ * @param userId 用户ID
+ * @param money 扣款金额
+ */
+ void debit(String userId, int money);
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java
new file mode 100644
index 000000000..fab053c86
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+public interface OrderService {
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void create(String userId, String commodityCode, int orderCount);
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java
new file mode 100644
index 000000000..d0922e579
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+public interface StorageService {
+
+ /**
+ * 扣减库存
+ *
+ * @param commodityCode 商品编号
+ * @param count 扣减数量
+ */
+ void deduct(String commodityCode, int count);
+
+ /**
+ * 批量扣减
+ *
+ * @param commodityCode
+ * @param count
+ */
+ void batchDeduct(String commodityCode, int count);
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml
new file mode 100644
index 000000000..7178780eb
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml
@@ -0,0 +1,123 @@
+
+
+
+ 4.0.0
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+
+ springboot-dubbo-seata-order
+ 2.0.0
+ springboot-dubbo-seata-order
+ springboot-dubbo-seata-order
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+
+ org.apache.dubbo
+ dubbo-spring-boot-starter
+ 3.1.2
+
+
+ org.apache.dubbo
+ dubbo-remoting-zookeeper-curator5
+ 3.1.2
+
+
+ org.apache.curator
+ curator-x-discovery
+ 5.1.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+ org.apache.seata
+ springboot-dubbo-seata-common
+ 2.0.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/SpringbootDubboSeataOrderApplication.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/SpringbootDubboSeataOrderApplication.java
new file mode 100644
index 000000000..a86a30a54
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/SpringbootDubboSeataOrderApplication.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootDubboSeataOrderApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringbootDubboSeataOrderApplication.class, args);
+ }
+
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..d0617e3ba
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.service.AccountService;
+import org.apache.seata.service.OrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+
+import javax.annotation.Resource;
+import java.sql.PreparedStatement;
+import java.util.Objects;
+
+@DubboService
+public class OrderServiceImpl implements OrderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @DubboReference
+ private AccountService accountService;
+
+ @Override
+ public void create(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
+
+ // 计算订单金额
+ int orderMoney = calculate(commodityCode, orderCount);
+
+ // 从账户余额扣款
+ accountService.debit(userId, orderMoney);
+
+ LOGGER.info(
+ "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
+ userId, commodityCode, orderCount, orderMoney);
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+ jdbcTemplate.update(con -> {
+ PreparedStatement pst = con.prepareStatement(
+ "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
+ PreparedStatement.RETURN_GENERATED_KEYS);
+ pst.setObject(1, userId);
+ pst.setObject(2, commodityCode);
+ pst.setObject(3, orderCount);
+ pst.setObject(4, orderMoney);
+ return pst;
+ }, keyHolder);
+
+
+ LOGGER.info("Order Service End ... Created " + Objects.requireNonNull(keyHolder.getKey()).longValue());
+ }
+
+ private int calculate(String commodityId, int orderCount) {
+ return 200 * orderCount;
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/all.sql b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/application.properties b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/application.properties
new file mode 100644
index 000000000..e192de12e
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+spring.application.name=springboot-dubbo-seata-order
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
+seata.application-id=springboot-dubbo-seata-order
+seata.tx-service-group=my_test_tx_group
+dubbo.scan.base-packages=org.apache.seata
+dubbo.application.qos-enable=false
+dubbo.registry.address=zookeeper://localhost:2181
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20883
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/file.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/registry.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml
new file mode 100644
index 000000000..2c3478b43
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml
@@ -0,0 +1,105 @@
+
+
+ 4.0.0
+
+ org.apache.seata
+ springboot-dubbo-seata
+ 2.0.0
+
+ springboot-dubbo-seata-storage
+ 2.0.0
+ springboot-dubbo-seata-storage
+ springboot-dubbo-seata-storage
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.9
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ 1.7.32
+
+
+ org.slf4j
+ log4j-over-slf4j
+ 1.7.32
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+
+ org.apache.dubbo
+ dubbo-spring-boot-starter
+ 3.1.2
+
+
+ org.apache.dubbo
+ dubbo-remoting-zookeeper-curator5
+ 3.1.2
+
+
+ org.apache.curator
+ curator-x-discovery
+ 5.1.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+ org.apache.seata
+ springboot-dubbo-seata-common
+ 2.0.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/SpringbootDubboSeataStorageApplication.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/SpringbootDubboSeataStorageApplication.java
new file mode 100644
index 000000000..d69a9c7f9
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/SpringbootDubboSeataStorageApplication.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootDubboSeataStorageApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringbootDubboSeataStorageApplication.class, args);
+ }
+
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..e53a2bb41
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.annotation.Resource;
+
+@DubboService
+public class StorageServiceImpl implements StorageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void deduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
+ count, commodityCode);
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+ @Override
+ public void batchDeduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.batchUpdate(
+ "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'",
+ "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'");
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+}
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/all.sql b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/application.properties b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/application.properties
new file mode 100644
index 000000000..33e291f1b
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+spring.application.name=springboot-dubbo-seata-storage
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
+seata.application-id=springboot-dubbo-seata-storage
+seata.tx-service-group=my_test_tx_group
+dubbo.scan.base-packages=org.apache.seata
+dubbo.application.qos-enable=false
+dubbo.registry.address=zookeeper://localhost:2181
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=20882
\ No newline at end of file
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/file.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/registry.conf b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-mybatis-seata/pom.xml b/at-sample/springboot-mybatis-seata/pom.xml
new file mode 100644
index 000000000..e073bade6
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/pom.xml
@@ -0,0 +1,88 @@
+
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.0
+
+
+ org.apache.seata
+ springboot-mybatis-seata
+ 2.0.0
+ springboot-mybatis-seata
+ springboot-mybatis-seata
+
+ 8
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.2.2
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java
new file mode 100644
index 000000000..d8a4255e0
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+import org.apache.seata.service.BusinessService;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootSeataApplication implements BeanFactoryAware {
+
+ private static BeanFactory BEAN_FACTORY;
+
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(SpringbootSeataApplication.class, args);
+
+ BusinessService businessService = BEAN_FACTORY.getBean(BusinessService.class);
+
+ Thread thread = new Thread(() -> businessService.purchase(TestData.USER_ID, TestData.COMMODITY_CODE, 2));
+ thread.start();
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ BEAN_FACTORY = beanFactory;
+ }
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/TestData.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/TestData.java
new file mode 100644
index 000000000..fe972868f
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/TestData.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata;
+
+public class TestData {
+
+ public static final String USER_ID = "U100001";
+ public static final String COMMODITY_CODE = "C00321";
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/AccountMapper.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/AccountMapper.java
new file mode 100644
index 000000000..78ba48cc6
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/AccountMapper.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.seata.model.Account;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface AccountMapper {
+
+ Account selectByUserId(@Param("userId") String userId);
+
+ int updateById(Account record);
+
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/OrderMapper.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/OrderMapper.java
new file mode 100644
index 000000000..814edc743
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/OrderMapper.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.seata.model.Order;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface OrderMapper {
+
+ int insert(Order record);
+
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/StorageMapper.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/StorageMapper.java
new file mode 100644
index 000000000..443e2e334
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/dao/StorageMapper.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.seata.model.Storage;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface StorageMapper {
+
+ Storage selectById(@Param("id") Integer id);
+
+ Storage findByCommodityCode(@Param("commodityCode") String commodityCode);
+
+ int updateById(Storage record);
+
+ void insert(Storage record);
+
+ void insertBatch(List records);
+
+ int updateBatch(@Param("list") List ids, @Param("commodityCode") String commodityCode);
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Account.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Account.java
new file mode 100644
index 000000000..b8aecbea8
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Account.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.model;
+
+public class Account {
+ private Integer id;
+
+ private String userId;
+
+ private Integer money;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public Integer getMoney() {
+ return money;
+ }
+
+ public void setMoney(Integer money) {
+ this.money = money;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Order.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Order.java
new file mode 100644
index 000000000..ad78960c4
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Order.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.model;
+
+import java.math.BigDecimal;
+
+public class Order {
+ private Integer id;
+
+ private String userId;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ private Integer money;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getCommodityCode() {
+ return commodityCode;
+ }
+
+ public void setCommodityCode(String commodityCode) {
+ this.commodityCode = commodityCode;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public Integer getMoney() {
+ return money;
+ }
+
+ public void setMoney(Integer money) {
+ this.money = money;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Storage.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Storage.java
new file mode 100644
index 000000000..fd9399486
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/model/Storage.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.model;
+
+public class Storage {
+
+ private Integer id;
+
+ private String commodityCode;
+
+ private Integer count;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCommodityCode() {
+ return commodityCode;
+ }
+
+ public void setCommodityCode(String commodityCode) {
+ this.commodityCode = commodityCode;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+}
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/AccountService.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/AccountService.java
new file mode 100644
index 000000000..2e8a75daa
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/AccountService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Account service.
+ */
+public interface AccountService {
+
+ /**
+ * 余额扣款
+ *
+ * @param userId 用户ID
+ * @param money 扣款金额
+ */
+ void debit(String userId, int money);
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/BusinessService.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/BusinessService.java
new file mode 100644
index 000000000..c6f16f415
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/BusinessService.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Business service.
+ */
+public interface BusinessService {
+
+ /**
+ * 用户订购商品
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void purchase(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/OrderService.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/OrderService.java
new file mode 100644
index 000000000..a360ca920
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/OrderService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+
+/**
+ * The interface Order service.
+ */
+public interface OrderService {
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void create(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/StorageService.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/StorageService.java
new file mode 100644
index 000000000..0f68fad94
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/StorageService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Stock service.
+ */
+public interface StorageService {
+
+ /**
+ * 扣减库存
+ *
+ * @param commodityCode 商品编号
+ * @param count 扣减数量
+ */
+ void deduct(String commodityCode, int count);
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..0af9a2082
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.dao.AccountMapper;
+import org.apache.seata.model.Account;
+import org.apache.seata.service.AccountService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+
+/**
+ * The type Account service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class AccountServiceImpl implements AccountService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
+
+ @Resource
+ private AccountMapper accountMapper;
+
+ @Override
+ public void debit(String userId, int money) {
+ LOGGER.info("Account Service ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
+ userId);
+ Account account = accountMapper.selectByUserId(userId);
+ account.setMoney(money);
+ accountMapper.updateById(account);
+ LOGGER.info("Account Service End ... ");
+ }
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..a97ff2fcb
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
+import org.apache.seata.TestData;
+import org.apache.seata.service.BusinessService;
+import org.apache.seata.service.OrderService;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.Random;
+
+/**
+ * The type Business service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class BusinessServiceImpl implements BusinessService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
+
+ @Resource
+ private StorageService storageService;
+ @Resource
+ private OrderService orderService;
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ private final Random random = new Random();
+
+ @Override
+ @GlobalTransactional(timeoutMills = 300000, name = "spring-seata-tx")
+ public void purchase(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
+ storageService.deduct(commodityCode, orderCount);
+ orderService.create(userId, commodityCode, orderCount);
+ if (random.nextBoolean()) {
+ throw new RuntimeException("random exception mock!");
+ }
+ }
+
+ @PostConstruct
+ public void initData() {
+ jdbcTemplate.update("delete from account_tbl");
+ jdbcTemplate.update("delete from order_tbl");
+ jdbcTemplate.update("delete from stock_tbl");
+ jdbcTemplate.update("insert into account_tbl(user_id,money) values('" + TestData.USER_ID + "','10000') ");
+ jdbcTemplate.update(
+ "insert into stock_tbl(commodity_code,count) values('" + TestData.COMMODITY_CODE + "','100') ");
+ }
+
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..38a7f4399
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.dao.OrderMapper;
+import org.apache.seata.model.Order;
+import org.apache.seata.service.AccountService;
+import org.apache.seata.service.OrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Order service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class OrderServiceImpl implements OrderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
+
+ @Resource
+ private AccountService accountService;
+ @Resource
+ private OrderMapper orderMapper;
+
+ @Override
+ public void create(String userId, String commodityCode, int count) {
+ LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
+ Order order = new Order();
+ order.setUserId(userId);
+ order.setCommodityCode(commodityCode);
+ order.setCount(count);
+ int orderMoney = calculate(commodityCode, count);
+ order.setMoney(orderMoney);
+
+ orderMapper.insert(order);
+ accountService.debit(userId, orderMoney);
+ }
+
+ private int calculate(String commodityCode, int count) {
+ return 200 * count;
+ }
+
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..cfe96d78d
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1999-2021 Seata.io Group.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.dao.StorageMapper;
+import org.apache.seata.model.Storage;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Stock service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class StorageServiceImpl implements StorageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class);
+
+ @Resource
+ private StorageMapper storageMapper;
+
+ @Override
+ public void deduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ Storage stock = storageMapper.findByCommodityCode(commodityCode);
+ stock.setCount(stock.getCount() - count);
+ storageMapper.updateById(stock);
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/all.sql b/at-sample/springboot-mybatis-seata/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/application.properties b/at-sample/springboot-mybatis-seata/src/main/resources/application.properties
new file mode 100644
index 000000000..61c3f524c
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/application.properties
@@ -0,0 +1,10 @@
+spring.application.name=springboot-mybatis-seata
+server.port=8088
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
+seata.application-id=springboot-mybatis-seata
+seata.tx-service-group=my_test_tx_group
+mybatis.configuration.map-underscore-to-camel-case=true
+mybatis.mapper-locations=classpath:mapper/*.xml
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/file.conf b/at-sample/springboot-mybatis-seata/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/mapper/AccountMapper.xml b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/AccountMapper.xml
new file mode 100644
index 000000000..328d01d5d
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/AccountMapper.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ update account_tbl
+ set money = #{money,jdbcType=INTEGER}
+ where id = #{id}
+
+
+
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/mapper/OrderMapper.xml b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/OrderMapper.xml
new file mode 100644
index 000000000..6343a18d9
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/OrderMapper.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ insert into order_tbl (user_id, commodity_code, count, money)
+ values (#{userId,jdbcType=VARCHAR}, #{commodityCode,jdbcType=VARCHAR}, #{count,jdbcType=INTEGER},
+ #{money,jdbcType=INTEGER})
+
+
+
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/mapper/StorageMapper.xml b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/StorageMapper.xml
new file mode 100644
index 000000000..6630a6aae
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/StorageMapper.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ update stock_tbl
+ set count = #{count,jdbcType=INTEGER}
+ WHERE id = #{id}
+
+
+
+ insert into stock_tbl (commodity_code, count)
+ values (#{commodityCode,jdbcType=VARCHAR}, #{count,jdbcType=INTEGER})
+
+
+
+ insert into stock_tbl (commodity_code, count)
+ values
+
+ (#{item.commodityCode,jdbcType=VARCHAR}, #{item.count,jdbcType=INTEGER})
+
+
+
+
+ update stock_tbl set count = 100
+ WHERE id IN
+
+ #{item}
+
+ and commodity_code = #{commodityCode,jdbcType=VARCHAR}
+
+
\ No newline at end of file
diff --git a/at-sample/springboot-mybatis-seata/src/main/resources/registry.conf b/at-sample/springboot-mybatis-seata/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/at-sample/springboot-seata/pom.xml b/at-sample/springboot-seata/pom.xml
new file mode 100644
index 000000000..a36f6abca
--- /dev/null
+++ b/at-sample/springboot-seata/pom.xml
@@ -0,0 +1,82 @@
+
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.0
+
+
+ org.apache.seata
+ springboot-seata
+ 2.0.0
+ springboot-seata
+ springboot-seata
+
+ 8
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 2.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.42
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java
new file mode 100644
index 000000000..32dc50aa3
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/SpringbootSeataApplication.java
@@ -0,0 +1,31 @@
+package org.apache.seata;
+
+import org.apache.seata.service.BusinessService;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringbootSeataApplication implements BeanFactoryAware {
+
+ private static BeanFactory BEAN_FACTORY;
+
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(SpringbootSeataApplication.class, args);
+
+ BusinessService businessService = BEAN_FACTORY.getBean(BusinessService.class);
+
+ Thread thread = new Thread(() -> businessService.purchase("U100001", "C00321", 2));
+ thread.start();
+
+ //keep run
+ Thread.currentThread().join();
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ BEAN_FACTORY = beanFactory;
+ }
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/AccountService.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/AccountService.java
new file mode 100644
index 000000000..2e8a75daa
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/AccountService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Account service.
+ */
+public interface AccountService {
+
+ /**
+ * 余额扣款
+ *
+ * @param userId 用户ID
+ * @param money 扣款金额
+ */
+ void debit(String userId, int money);
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/BusinessService.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/BusinessService.java
new file mode 100644
index 000000000..c6f16f415
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/BusinessService.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Business service.
+ */
+public interface BusinessService {
+
+ /**
+ * 用户订购商品
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void purchase(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/OrderService.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/OrderService.java
new file mode 100644
index 000000000..a360ca920
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/OrderService.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+
+/**
+ * The interface Order service.
+ */
+public interface OrderService {
+
+ /**
+ * 创建订单
+ *
+ * @param userId 用户ID
+ * @param commodityCode 商品编号
+ * @param orderCount 订购数量
+ */
+ void create(String userId, String commodityCode, int orderCount);
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/StorageService.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/StorageService.java
new file mode 100644
index 000000000..0f68fad94
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/StorageService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service;
+
+/**
+ * The interface Stock service.
+ */
+public interface StorageService {
+
+ /**
+ * 扣减库存
+ *
+ * @param commodityCode 商品编号
+ * @param count 扣减数量
+ */
+ void deduct(String commodityCode, int count);
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
new file mode 100644
index 000000000..ab3482aeb
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/AccountServiceImpl.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.AccountService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Account service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class AccountServiceImpl implements AccountService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void debit(String userId, int money) {
+ LOGGER.info("Account Service ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
+ userId);
+
+ jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", money, userId);
+ LOGGER.info("Account Service End ... ");
+ }
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
new file mode 100644
index 000000000..b5d122baf
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/BusinessServiceImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import io.seata.spring.annotation.GlobalTransactional;
+import org.apache.seata.service.BusinessService;
+import org.apache.seata.service.OrderService;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Random;
+
+/**
+ * The type Business service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class BusinessServiceImpl implements BusinessService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
+
+ @Resource
+ private StorageService storageService;
+ @Resource
+ private OrderService orderService;
+
+ private final Random random = new Random();
+
+ @Override
+ @GlobalTransactional(timeoutMills = 300000, name = "spring-seata-tx")
+ public void purchase(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
+ storageService.deduct(commodityCode, orderCount);
+ orderService.create(userId, commodityCode, orderCount);
+ if (random.nextBoolean()) {
+ throw new RuntimeException("random exception mock!");
+ }
+ }
+
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
new file mode 100644
index 000000000..7aede43d7
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/OrderServiceImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.AccountService;
+import org.apache.seata.service.OrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.PreparedStatement;
+import java.util.Objects;
+
+/**
+ * The type Order service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class OrderServiceImpl implements OrderService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
+
+ @Resource
+ private AccountService accountService;
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void create(String userId, String commodityCode, int orderCount) {
+ LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
+
+ // 计算订单金额
+ int orderMoney = calculate(commodityCode, orderCount);
+
+ // 从账户余额扣款
+ accountService.debit(userId, orderMoney);
+
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+
+ LOGGER.info(
+ "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
+ userId, commodityCode, orderCount, orderMoney);
+
+ jdbcTemplate.update(con -> {
+ PreparedStatement pst = con.prepareStatement(
+ "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
+ PreparedStatement.RETURN_GENERATED_KEYS);
+ pst.setObject(1, userId);
+ pst.setObject(2, commodityCode);
+ pst.setObject(3, orderCount);
+ pst.setObject(4, orderMoney);
+ return pst;
+ }, keyHolder);
+
+
+ LOGGER.info("Order Service End ... Created " + Objects.requireNonNull(keyHolder.getKey()).longValue());
+ }
+
+ private int calculate(String commodityId, int orderCount) {
+ return 200 * orderCount;
+ }
+
+}
diff --git a/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
new file mode 100644
index 000000000..8ee0cc42d
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/java/org/apache/seata/service/impl/StorageServiceImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2021 Seata.io Group.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.service.impl;
+
+import io.seata.core.context.RootContext;
+import org.apache.seata.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * The type Stock service.
+ *
+ * @author jimin.jm @alibaba-inc.com
+ */
+@Service
+public class StorageServiceImpl implements StorageService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StorageService.class);
+
+ @Resource
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public void deduct(String commodityCode, int count) {
+ LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
+ LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
+ commodityCode);
+
+ jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
+ new Object[]{count, commodityCode});
+ LOGGER.info("Stock Service End ... ");
+
+ }
+
+}
diff --git a/at-sample/springboot-seata/src/main/resources/all.sql b/at-sample/springboot-seata/src/main/resources/all.sql
new file mode 100644
index 000000000..a6974d7f6
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/resources/all.sql
@@ -0,0 +1,56 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE TABLE `account_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `stock_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `commodity_code` (`commodity_code`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `order_tbl`
+(
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_id` varchar(255) DEFAULT NULL,
+ `commodity_code` varchar(255) DEFAULT NULL,
+ `count` int(11) DEFAULT '0',
+ `money` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `undo_log`
+(
+ `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
+ `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
+ `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
+ `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
+ `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
+ `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
+ `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
+ UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
+ ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
+ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);
\ No newline at end of file
diff --git a/at-sample/springboot-seata/src/main/resources/application.properties b/at-sample/springboot-seata/src/main/resources/application.properties
new file mode 100644
index 000000000..45ba421f4
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+spring.application.name=springboot-seata
+server.port=8088
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/seata?userSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=123456
+seata.application-id=springboot-seata
+seata.tx-service-group=my_test_tx_group
\ No newline at end of file
diff --git a/at-sample/springboot-seata/src/main/resources/file.conf b/at-sample/springboot-seata/src/main/resources/file.conf
new file mode 100644
index 000000000..e426f6661
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/resources/file.conf
@@ -0,0 +1,126 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+transport {
+ # tcp, unix-domain-socket
+ type = "TCP"
+ #NIO, NATIVE
+ server = "NIO"
+ #enable heartbeat
+ heartbeat = true
+ # the tm client batch send request enable
+ enableTmClientBatchSendRequest = false
+ # the rm client batch send request enable
+ enableRmClientBatchSendRequest = true
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 2000
+ # the tm client rpc request timeout
+ rpcTmRequestTimeout = 30000
+ # the rm client rpc request timeout
+ rpcRmRequestTimeout = 15000
+ #thread factory for netty
+ threadFactory {
+ bossThreadPrefix = "NettyBoss"
+ workerThreadPrefix = "NettyServerNIOWorker"
+ serverExecutorThread-prefix = "NettyServerBizHandler"
+ shareBossWorker = false
+ clientSelectorThreadPrefix = "NettyClientSelector"
+ clientSelectorThreadSize = 1
+ clientWorkerThreadPrefix = "NettyClientWorkerThread"
+ # netty boss thread size
+ bossThreadSize = 1
+ #auto default pin or 8
+ workerThreadSize = "default"
+ }
+ shutdown {
+ # when destroy server, wait seconds
+ wait = 3
+ }
+ serialization = "seata"
+ compressor = "none"
+}
+service {
+ #transaction service group mapping
+ vgroupMapping.my_test_tx_group = "default"
+ #only support when registry.type=file, please don't set multiple addresses
+ default.grouplist = "127.0.0.1:8091"
+ #degrade, current not support
+ enableDegrade = false
+ #disable seata
+ disableGlobalTransaction = false
+}
+
+client {
+ rm {
+ asyncCommitBufferLimit = 10000
+ lock {
+ retryInterval = 10
+ retryTimes = 30
+ retryPolicyBranchRollbackOnConflict = true
+ }
+ reportRetryCount = 5
+ tableMetaCheckEnable = false
+ tableMetaCheckerInterval = 60000
+ reportSuccessEnable = false
+ sagaBranchRegisterEnable = false
+ sagaJsonParser = "fastjson"
+ sagaRetryPersistModeUpdate = false
+ sagaCompensatePersistModeUpdate = false
+ tccActionInterceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ sqlParserType = "druid"
+ branchExecutionTimeoutXA = 60000
+ connectionTwoPhaseHoldTimeoutXA = 10000
+ }
+ tm {
+ commitRetryCount = 5
+ rollbackRetryCount = 5
+ defaultGlobalTransactionTimeout = 60000
+ degradeCheck = false
+ degradeCheckPeriod = 2000
+ degradeCheckAllowTimes = 10
+ interceptorOrder = -2147482648 #Ordered.HIGHEST_PRECEDENCE + 1000
+ }
+ undo {
+ dataValidation = true
+ onlyCareUpdateColumns = true
+ logSerialization = "jackson"
+ logTable = "undo_log"
+ compress {
+ enable = true
+ # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip
+ type = zip
+ # if rollback info size > threshold, then will be compress
+ # allow k m g t
+ threshold = 64k
+ }
+ }
+ loadBalance {
+ type = "XID"
+ virtualNodes = 10
+ }
+}
+log {
+ exceptionRate = 100
+}
+tcc {
+ fence {
+ # tcc fence log table name
+ logTableName = tcc_fence_log
+ # tcc fence log clean period
+ cleanPeriod = 1h
+ }
+}
diff --git a/at-sample/springboot-seata/src/main/resources/registry.conf b/at-sample/springboot-seata/src/main/resources/registry.conf
new file mode 100644
index 000000000..a105dc3e8
--- /dev/null
+++ b/at-sample/springboot-seata/src/main/resources/registry.conf
@@ -0,0 +1,124 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa、custom
+ type = "file"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "127.0.0.1:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ ##if use Nacos naming meta-data for SLB service registry, specify nacos address pattern rules here
+ #slbPattern = ""
+ }
+ eureka {
+ serviceUrl = "http://localhost:8761/eureka"
+ weight = "1"
+ }
+ redis {
+ serverAddr = "localhost:6379"
+ db = "0"
+ password = ""
+ timeout = "0"
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ aclToken = ""
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ }
+ sofa {
+ serverAddr = "127.0.0.1:9603"
+ region = "DEFAULT_ZONE"
+ datacenter = "DefaultDataCenter"
+ group = "SEATA_GROUP"
+ addressWaitTime = "3000"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig、custom
+ type = "file"
+ raft {
+ metadata-max-age-ms = 30000
+ serverAddr = "127.0.0.1:8848"
+ }
+ nacos {
+ serverAddr = "127.0.0.1:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = ""
+ password = ""
+ contextPath = ""
+ ##if use MSE Nacos with auth, mutex with username/password attribute
+ #accessKey = ""
+ #secretKey = ""
+ dataId = "seata.properties"
+ }
+ consul {
+ serverAddr = "127.0.0.1:8500"
+ key = "seata.properties"
+ aclToken = ""
+ }
+ apollo {
+ appId = "seata-server"
+ apolloMeta = "http://192.168.1.204:8801"
+ namespace = "application"
+ apolloAccesskeySecret = ""
+ cluster = ""
+ }
+ zk {
+ serverAddr = "127.0.0.1:2181"
+ sessionTimeout = 6000
+ connectTimeout = 2000
+ username = ""
+ password = ""
+ nodePath = "/seata/seata.properties"
+ }
+ etcd3 {
+ serverAddr = "http://localhost:2379"
+ key = "seata.properties"
+ }
+ file {
+ name = "file.conf"
+ }
+ custom {
+ name = ""
+ }
+}
diff --git a/doc/img/fescar-1.png b/doc/img/fescar-1.png
deleted file mode 100644
index fa009f41b..000000000
Binary files a/doc/img/fescar-1.png and /dev/null differ
diff --git a/doc/img/fescar-2.png b/doc/img/fescar-2.png
deleted file mode 100644
index 38b9a6c0f..000000000
Binary files a/doc/img/fescar-2.png and /dev/null differ
diff --git a/doc/img/fescar.png b/doc/img/fescar.png
deleted file mode 100644
index 6804b6942..000000000
Binary files a/doc/img/fescar.png and /dev/null differ
diff --git a/doc/img/nacos-1.png b/doc/img/nacos-1.png
deleted file mode 100644
index 448d6ff51..000000000
Binary files a/doc/img/nacos-1.png and /dev/null differ
diff --git a/doc/img/nacos-2.png b/doc/img/nacos-2.png
deleted file mode 100644
index 06a43dc3a..000000000
Binary files a/doc/img/nacos-2.png and /dev/null differ
diff --git a/doc/img/nacos-3.png b/doc/img/nacos-3.png
deleted file mode 100644
index 32aa4bc96..000000000
Binary files a/doc/img/nacos-3.png and /dev/null differ
diff --git a/doc/img/seata.png b/doc/img/seata.png
deleted file mode 100644
index a9a43c1a4..000000000
Binary files a/doc/img/seata.png and /dev/null differ
diff --git a/doc/quick-integration-with-spring-cloud.md b/doc/quick-integration-with-spring-cloud.md
deleted file mode 100644
index 8b994194e..000000000
--- a/doc/quick-integration-with-spring-cloud.md
+++ /dev/null
@@ -1,394 +0,0 @@
-# Spring Cloud 快速集成 Seata
-
-### 1. 添加依赖
-
-添加Spring Cloud Alibaba 依赖管理工具和 Seata 依赖
-
-
-Gradle
-
-```groovy
-dependencyManagement {
- imports {
- mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:2.1.0.RELEASE"
- }
-}
-```
-
-```
-dependencies {
- compile('com.alibaba.cloud:spring-cloud-starter-alibaba-seata')
-}
-```
-
-
-
-
-Maven
-
-```xml
-
-
-
- com.alibaba.cloud
- spring-cloud-alibaba-dependencies
- 2.1.0.RELEASE
- pom
- import
-
-
-
-```
-
-```xml
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-seata
-
-```
-
-
-
-
-需要注意的是Spring Cloud Alibaba 的毕业版本的 GroupId 是 `com.alibaba.cloud`
-
-`spring-cloud-starter-alibaba-seata`这个依赖中只依赖了`spring-cloud-alibaba-seata`,所以在项目中添加`spring-cloud-starter-alibaba-seata`
-和`spring-cloud-alibaba-seata`是一样的
-
-### 2. 添加Seata 配置文件
-
-#### registry.conf
-
-该配置用于指定 TC 的注册中心和配置文件,默认都是 file; 如果使用其他的注册中心,要求 Seata-Server 也注册到该配置中心上
-
-
-registry.conf
-
-```
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "file"
-
- nacos {
- serverAddr = "localhost"
- namespace = "public"
- cluster = "default"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = "0"
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "file"
-
- nacos {
- serverAddr = "localhost"
- namespace = "public"
- cluster = "default"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- apollo {
- app.id = "seata-server"
- apollo.meta = "http://192.168.1.204:8801"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
-```
-
-
-
-#### file.conf
-
-该配置用于指定TC的相关属性;如果使用注册中心也可以将配置添加到配置中心
-
-
-file.conf
-
-```
-transport {
- # tcp udt unix-domain-socket
- type = "TCP"
- #NIO NATIVE
- server = "NIO"
- #enable heartbeat
- heartbeat = true
- #thread factory for netty
- thread-factory {
- boss-thread-prefix = "NettyBoss"
- worker-thread-prefix = "NettyServerNIOWorker"
- server-executor-thread-prefix = "NettyServerBizHandler"
- share-boss-worker = false
- client-selector-thread-prefix = "NettyClientSelector"
- client-selector-thread-size = 1
- client-worker-thread-prefix = "NettyClientWorkerThread"
- # netty boss thread size,will not be used for UDT
- boss-thread-size = 1
- #auto default pin or 8
- worker-thread-size = 8
- }
- shutdown {
- # when destroy server, wait seconds
- wait = 3
- }
- serialization = "seata"
- compressor = "none"
-}
-service {
- #vgroup->rgroup
- vgroupMapping.my_test_tx_group = "default"
- #only support single node
- default.grouplist = "127.0.0.1:8091"
- #degrade current not support
- enableDegrade = false
- #disable
- disable = false
- #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
- max.commit.retry.timeout = "-1"
- max.rollback.retry.timeout = "-1"
-}
-
-client {
- async.commit.buffer.limit = 10000
- lock {
- retry.internal = 10
- retry.times = 30
- }
- report.retry.count = 5
-}
-
-## transaction log store
-store {
- ## store mode: file、db
- mode = "file"
-
- ## file store
- file {
- dir = "sessionStore"
-
- # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
- max-branch-session-size = 16384
- # globe session size , if exceeded throws exceptions
- max-global-session-size = 512
- # file buffer size , if exceeded allocate new buffer
- file-write-buffer-cache-size = 16384
- # when recover batch read size
- session.reload.read_size = 100
- # async, sync
- flush-disk-mode = async
- }
-
- ## database store
- db {
- ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
- datasource = "dbcp"
- ## mysql/oracle/h2/oceanbase etc.
- db-type = "mysql"
- url = "jdbc:mysql://127.0.0.1:3306/seata"
- user = "mysql"
- password = "mysql"
- min-conn = 1
- max-conn = 3
- global.table = "global_table"
- branch.table = "branch_table"
- lock-table = "lock_table"
- query-limit = 100
- }
-}
-lock {
- ## the lock store mode: local、remote
- mode = "remote"
-
- local {
- ## store locks in user's database
- }
-
- remote {
- ## store locks in the seata's server
- }
-}
-recovery {
- committing-retry-delay = 30
- asyn-committing-retry-delay = 30
- rollbacking-retry-delay = 30
- timeout-retry-delay = 30
-}
-
-transaction {
- undo.data.validation = true
- undo.log.serialization = "jackson"
-}
-
-## metrics settings
-metrics {
- enabled = false
- registry-type = "compact"
- # multi exporters use comma divided
- exporter-list = "prometheus"
- exporter-prometheus-port = 9898
-}
-```
-
-
-
-需要注意的是 `service.vgroup_mapping`这个配置,在 Spring Cloud 中默认是`${spring.application.name}-fescar-service-group`
-,可以通过指定`application.properties`的 `spring.cloud.alibaba.seata.tx-service-group`这个属性覆盖,但是必须要和 `file.conf `
-中的一致,否则会提示 `no available server to connect`
-
-### 3. 注入数据源
-
-Seata 通过代理数据源的方式实现分支事务;MyBatis 和 JPA 都需要注入 `io.seata.rm.datasource.DataSourceProxy`, 不同的是,MyBatis
-还需要额外注入 `org.apache.ibatis.session.SqlSessionFactory`
-
-
-MyBatis
-
-```java
-@Configuration
-public class DataSourceProxyConfig {
-
- @Bean
- @ConfigurationProperties(prefix = "spring.datasource")
- public DataSource dataSource() {
- return new DruidDataSource();
- }
-
- @Bean
- public DataSourceProxy dataSourceProxy(DataSource dataSource) {
- return new DataSourceProxy(dataSource);
- }
-
- @Bean
- public SqlSessionFactory sqlSessionFactoryBean(DataSourceProxy dataSourceProxy) throws Exception {
- SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
- sqlSessionFactoryBean.setDataSource(dataSourceProxy);
- return sqlSessionFactoryBean.getObject();
- }
-}
-```
-
-
-
-
-
-JPA
-
-```java
-@Configuration
-public class DataSourceProxyConfig {
-
- @Bean
- @ConfigurationProperties(prefix = "spring.datasource")
- public DruidDataSource druidDataSource() {
- return new DruidDataSource();
- }
-
- @Primary
- @Bean
- public DataSourceProxy dataSource(DruidDataSource druidDataSource) {
- return new DataSourceProxy(druidDataSource);
- }
-
-}
-```
-
-
-
-如果使用的是 Hikari 数据源,需要修改数据源的配置,以及注入的 Bean 的配置前缀
-
-```
-spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.hikari.jdbc-url=jdbc:mysql://localhost:3306/seata?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false
-spring.datasource.hikari.username=root
-spring.datasource.hikari.password=123456
-```
-
-```java
-@Bean
-@ConfigurationProperties(prefix = "spring.datasource.hikari")
-public DataSource dataSource() {
- return new HikariDataSource();
-}
-```
-
-### 4. 添加 undo_log 表
-
-在业务相关的数据库中添加 undo_log 表,用于保存需要回滚的数据
-
-```sql
-CREATE TABLE `undo_log`
-(
- `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
- `branch_id` BIGINT(20) NOT NULL,
- `xid` VARCHAR(100) NOT NULL,
- `context` VARCHAR(128) NOT NULL,
- `rollback_info` LONGBLOB NOT NULL,
- `log_status` INT(11) NOT NULL,
- `log_created` DATETIME NOT NULL,
- `log_modified` DATETIME NOT NULL,
- `ext` VARCHAR(100) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
-) ENGINE = InnoDB
- AUTO_INCREMENT = 1
- DEFAULT CHARSET = utf8
-```
-
-### 5. 启动 Seata-Server
-
-在 [https://github.com/seata/seata/releases](https://github.com/seata/seata/releases) 下载相应版本的
-Seata-Server,修改 `registry.conf`为相应的配置(如果使用 file 则不需要修改),解压并通过以下命令启动:
-
-```bash
-sh ./bin/seata-server.sh
-```
-
-### 6. 使用`@GlobalTransactional`开启事务
-
-在业务的发起方的方法上使用`@GlobalTransactional`开启全局事务,Seata 会将事务的 xid 通过拦截器添加到调用其他服务的请求中,实现分布式事务
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/README.md b/dubbo-multiple-datasource-mybatis-plus/README.md
deleted file mode 100644
index 94bd00df1..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# SpringBoot-Dubbo使用 Seata 实现分布式事务 - MyBatisPlus动态数据源-Nacos为配置/注册中心
-
-> 使用 Seata 作为分布式事务组件,使用 MySQL 数据库,使用 MyBatis 作为数据访问层实现多数据源下事务一致,使用 MyBatisPlus 作为 MyBatis 的辅助工具,Nacos为配置/注册中心
-
-## 环境准备
-
-### 创建数据库及表
-
-根据sql文件夹内的sql文件名创建对应表,运行sql
-
-### 安装Seata跟Nacos
-
-按照该篇[文章](http://seata.io/zh-cn/blog/seata-nacos-analysis.html)安装seata跟nacos配置
-
-## 测试
-
-- 先后启动provider跟comsumer
-- 测试mp分页查询是否启用: http://127.0.0.1:28888/test/pageByProduct
-- 测试事务回滚: http://127.0.0.1:28888/test/testRollback
-- 测试事务提交: http://127.0.0.1:28888/test/testCommit
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/pom.xml b/dubbo-multiple-datasource-mybatis-plus/common/pom.xml
deleted file mode 100644
index b25228a0d..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/pom.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- dubbo-multiple-datasource-mybatis-plus
- io.seata.samples
- 1.1.0
-
- 4.0.0
-
- common
-
-
- 8
- 8
-
-
-
\ No newline at end of file
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Account.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Account.java
deleted file mode 100644
index aa545997a..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Account.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Account implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private String userName;
-
- private Integer sum;
-
- private LocalDateTime lastUpdateTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Orders.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Orders.java
deleted file mode 100644
index af3b250b9..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Orders.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Orders implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private Integer productId;
-
- private BigDecimal amount;
-
- private Integer sum;
-
- private Integer accountId;
-
- private LocalDateTime createTime;
-
- private LocalDateTime replaceTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Product.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Product.java
deleted file mode 100644
index 85d75bbab..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/entity/Product.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Product implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private BigDecimal price;
-
- private Integer stock;
-
- private Integer accountId;
-
- private LocalDateTime lastUpdateTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/DemoService.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/DemoService.java
deleted file mode 100644
index 326e637ae..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/DemoService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.spring.annotation.GlobalTransactional;
-
-/**
- * @author 陈健斌
- * @date 2019/12/05
- */
-public interface DemoService {
-
- /**
- * @return
- * @throws TransactionException
- */
- public Object testRollback() throws TransactionException;
-
- /**
- * @return
- * @throws TransactionException
- */
- public Object testCommit() throws TransactionException;
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IAccountService.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IAccountService.java
deleted file mode 100644
index 8f378a6f9..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IAccountService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Account;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IAccountService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IOrdersService.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IOrdersService.java
deleted file mode 100644
index 6ba34f8b1..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IOrdersService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Orders;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IOrdersService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IProductService.java b/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IProductService.java
deleted file mode 100644
index be73f2503..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/common/src/main/java/io/seata/samples/service/IProductService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Product;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IProductService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/pom.xml b/dubbo-multiple-datasource-mybatis-plus/consumer/pom.xml
deleted file mode 100644
index bfa8462f0..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- 4.0.0
-
- io.seata
- dubbo-multiple-datasource-mybatis-plus
- 1.1.0
-
- consumer
- consumer
- http://maven.apache.org
-
- UTF-8
-
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/ClientApplication.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/ClientApplication.java
deleted file mode 100644
index fa31531a5..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/ClientApplication.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples;
-
-import java.util.TimeZone;
-import java.util.concurrent.Executor;
-
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
-
-@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, MybatisPlusAutoConfiguration.class})
-@EnableDubbo(scanBasePackages = {"io.seata.samples.service"})
-public class ClientApplication {
- public static void main(String[] args) {
- TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
- SpringApplication app = new SpringApplication(ClientApplication.class);
- app.run(args);
- }
-
- @Bean(name = "threadPoolTaskExecutor")
- public Executor threadPoolTaskExecutor() {
- return new ThreadPoolTaskExecutor();
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/config/SeataAutoConfig.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/config/SeataAutoConfig.java
deleted file mode 100644
index 82517b7ef..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/config/SeataAutoConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.config;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import io.seata.spring.annotation.GlobalTransactionScanner;
-
-@Configuration
-public class SeataAutoConfig {
- private final static Logger logger = LoggerFactory.getLogger(SeataAutoConfig.class);
-
- /**
- * init global transaction scanner
- *
- * @Return: GlobalTransactionScanner
- */
- @Bean
- public GlobalTransactionScanner globalTransactionScanner() {
- logger.info("配置seata........");
- return new GlobalTransactionScanner("test-consumer", "my_test_tx_group");
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/controller/TestController.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/controller/TestController.java
deleted file mode 100644
index 3e6bd28b3..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/controller/TestController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.controller;
-
-import org.apache.dubbo.config.annotation.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.samples.entity.Product;
-import io.seata.samples.service.DemoService;
-import io.seata.samples.service.IProductService;
-
-/**
- *
- * 文件表 前端控制器
- *
- *
- * @author funkye
- * @since 2019-03-20
- */
-@RestController
-@RequestMapping("/test")
-public class TestController {
-
- private final static Logger logger = LoggerFactory.getLogger(TestController.class);
- @Reference(version = "1.0.0", timeout = 60000)
- DemoService demoService;
- @Reference(version = "1.0.0", timeout = 60000)
- private IProductService productService;
-
- /**
- * 测试mp分页插件是否生效
- *
- * @return
- */
- @GetMapping(value = "pageByProduct")
- public Object pageByProduct() {
- return productService.page(new Page(1, 10));
- }
-
- /**
- * 测试事务提交
- *
- * @return
- * @throws TransactionException
- */
- @GetMapping(value = "testCommit")
- public Object testCommit() throws TransactionException {
- return demoService.testCommit();
- }
-
- /**
- * 测试事务回滚
- *
- * @return
- * @throws TransactionException
- */
- @GetMapping(value = "testRollback")
- public Object testRollback() throws TransactionException {
- return demoService.testRollback();
- }
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Account.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Account.java
deleted file mode 100644
index aa545997a..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Account.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Account implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private String userName;
-
- private Integer sum;
-
- private LocalDateTime lastUpdateTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Orders.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Orders.java
deleted file mode 100644
index af3b250b9..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Orders.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Orders implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private Integer productId;
-
- private BigDecimal amount;
-
- private Integer sum;
-
- private Integer accountId;
-
- private LocalDateTime createTime;
-
- private LocalDateTime replaceTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Product.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Product.java
deleted file mode 100644
index 85d75bbab..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/entity/Product.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.entity;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class Product implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- private BigDecimal price;
-
- private Integer stock;
-
- private Integer accountId;
-
- private LocalDateTime lastUpdateTime;
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoService.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoService.java
deleted file mode 100644
index 71d2b44a7..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.spring.annotation.GlobalTransactional;
-
-/**
- * @author 陈健斌
- * @date 2019/12/05
- */
-public interface DemoService {
-
- /**
- * @return
- * @throws TransactionException
- */
- public Object testRollback() throws TransactionException;
-
- /**
- * @return
- * @throws TransactionException
- */
- @GlobalTransactional
- public Object testCommit() throws TransactionException;
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoServiceImpl.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoServiceImpl.java
deleted file mode 100644
index dc8148b0d..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/DemoServiceImpl.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import java.time.LocalDateTime;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.apache.dubbo.config.annotation.DubboService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-
-import io.seata.core.context.RootContext;
-import io.seata.core.exception.TransactionException;
-import io.seata.samples.entity.Account;
-import io.seata.samples.entity.Orders;
-import io.seata.samples.entity.Product;
-import io.seata.spring.annotation.GlobalTransactional;
-import io.seata.tm.api.GlobalTransactionContext;
-import org.springframework.stereotype.Service;
-
-/**
- * @author 陈健斌
- * @date 2019/12/05
- */
-@Service
-public class DemoServiceImpl implements DemoService {
- private final static Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
- @DubboReference(version = "1.0.0", timeout = 60000, check = false)
- private IAccountService accountService;
- @DubboReference(version = "1.0.0", timeout = 60000, check = false)
- private IOrdersService ordersService;
- @DubboReference(version = "1.0.0", timeout = 60000, check = false)
- private IProductService productService;
- private Lock lock = new ReentrantLock();
-
- /**
- * @return
- * @throws TransactionException
- */
- @Override
- @GlobalTransactional
- public Object testRollback() throws TransactionException {
- logger.info("seata分布式事务Id:{}", RootContext.getXID());
- lock.lock();
- try {
- LocalDateTime now = LocalDateTime.now();
- Product product = productService.getOne(Wrappers.query().eq("id", 1).last("for update"));
- if (product.getStock() > 0) {
- Account account = accountService.getById(1);
- Orders orders = new Orders();
- orders.setCreateTime(now);
- orders.setProductId(product.getId());
- orders.setReplaceTime(now);
- orders.setSum(1);
- orders.setAmount(product.getPrice());
- orders.setAccountId(account.getId());
- product.setStock(product.getStock() - 1);
- account.setSum(account.getSum() != null ? account.getSum() + 1 : 1);
- account.setLastUpdateTime(now);
- productService.updateById(product);
- accountService.updateById(account);
- ordersService.save(orders);
- int i = 1 / 0;
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- // TODO: handle exception
- logger.info("载入事务id进行回滚");
- GlobalTransactionContext.reload(RootContext.getXID()).rollback();
- return false;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @return
- * @throws TransactionException
- */
- @Override
- @GlobalTransactional
- public Object testCommit() throws TransactionException {
- lock.lock();
- try {
- LocalDateTime now = LocalDateTime.now();
- Product product = productService.getOne(Wrappers.query().eq("id", 1).last("for update"));
- if (product.getStock() > 0) {
- logger.info("seata分布式事务Id:{}", RootContext.getXID());
- Account account = accountService.getById(1);
- Orders orders = new Orders();
- orders.setCreateTime(now);
- orders.setProductId(product.getId());
- orders.setReplaceTime(now);
- orders.setSum(1);
- orders.setAmount(product.getPrice());
- orders.setAccountId(account.getId());
- product.setStock(product.getStock() - 1);
- account.setSum(account.getSum() != null ? account.getSum() + 1 : 1);
- account.setLastUpdateTime(now);
- productService.updateById(product);
- accountService.updateById(account);
- ordersService.save(orders);
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- // TODO: handle exception
- logger.info("载入事务{}进行回滚" + e.getMessage(), RootContext.getXID());
- GlobalTransactionContext.reload(RootContext.getXID()).rollback();
- return false;
- } finally {
- lock.unlock();
- }
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IAccountService.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IAccountService.java
deleted file mode 100644
index 8f378a6f9..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IAccountService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Account;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IAccountService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IOrdersService.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IOrdersService.java
deleted file mode 100644
index 6ba34f8b1..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IOrdersService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Orders;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IOrdersService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IProductService.java b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IProductService.java
deleted file mode 100644
index be73f2503..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/java/io/seata/samples/service/IProductService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import io.seata.samples.entity.Product;
-
-/**
- *
- * 功能 服务类
- *
- *
- * @author Funkye
- * @since 2019-04-10
- */
-public interface IProductService extends IService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/application.yml b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/application.yml
deleted file mode 100644
index 15468eae0..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/application.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-spring:
- application:
- name: test-consumer
- datasource:
- driver-class-name: com.mysql.jdbc.Driver
- url: jdbc:mysql://127.0.0.1:3306/test?userSSL=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=Asia/Shanghai
- username: root
- password: 123456
- mvc:
- servlet:
- load-on-startup: 1
- http:
- encoding:
- force: true
- charset: utf-8
- enabled: true
- multipart:
- max-file-size: 10MB
- max-request-size: 10MB
-dubbo:
- registry:
- id: my-registry
- address: nacos://127.0.0.1:8848
- application:
- name: test-consumer
- qos-enable: false
-server:
- port: 28888
- max-http-header-size: 8192
- address: 0.0.0.0
- tomcat:
- max-http-post-size: 104857600
\ No newline at end of file
diff --git a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/registry.conf b/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/registry.conf
deleted file mode 100644
index 0700885ff..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/consumer/src/main/resources/registry.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- cluster = "default"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = "0"
- password = ""
- cluster = "default"
- timeout = "0"
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
- type = "nacos"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- group = "SEATA_GROUP"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- apollo {
- app.id = "seata-server"
- apollo.meta = "http://192.168.1.204:8801"
- namespace = "application"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/pom.xml b/dubbo-multiple-datasource-mybatis-plus/pom.xml
deleted file mode 100644
index 05c028bc2..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/pom.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
- 4.0.0
- io.seata.samples
- dubbo-multiple-datasource-mybatis-plus
- 1.1.0
- dubbo-multiple-datasource-mybatis-plus
- http://maven.apache.org
-
- 3.1
- UTF-8
- UTF-8
- 1.8
- 1.8
- 3.3.0
- 2.7.15
- 2.3.1.RELEASE
-
-
-
- org.mybatis
- mybatis-typehandlers-jsr310
- 1.0.2
-
-
- com.alibaba.nacos
- nacos-client
- 1.1.4
-
-
- org.apache.dubbo
- dubbo-registry-nacos
- ${dubbo.version}
-
-
- org.apache.dubbo
- dubbo-spring-boot-starter
- ${dubbo.version}
-
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus-boot-starter.version}
-
-
-
- org.projectlombok
- lombok
- provided
- 1.18.8
-
-
- io.seata
- seata-all
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.1.20
-
-
- mysql
- mysql-connector-java
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- pom
-
- provider
- consumer
- common
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-dependencies
- ${spring-boot.version}
- pom
- import
-
-
-
- io.seata
- seata-all
- 1.4.2
-
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/pom.xml b/dubbo-multiple-datasource-mybatis-plus/provider/pom.xml
deleted file mode 100644
index 060f9f066..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 4.0.0
-
- io.seata.samples
- dubbo-multiple-datasource-mybatis-plus
- 1.1.0
-
- provider
- provider
- http://maven.apache.org
-
- UTF-8
-
-
-
- io.seata.samples
- common
- 1.1.0
-
-
- com.baomidou
- dynamic-datasource-spring-boot-starter
- 3.0.0
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/ProviderApplication.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/ProviderApplication.java
deleted file mode 100644
index 5133501e3..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/ProviderApplication.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
-
-/**
- * @author funkye
- * @date 2019/12/7
- */
-@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class})
-public class ProviderApplication {
-
- public static void main(String[] args) {
- SpringApplication app = new SpringApplication(ProviderApplication.class);
- app.run(args);
- }
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/MybatisPlusConfig.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/MybatisPlusConfig.java
deleted file mode 100644
index 74b33021c..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/MybatisPlusConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import com.baomidou.mybatisplus.core.parser.ISqlParser;
-import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-
-@Configuration
-@MapperScan("io.seata.samples.mapper*")
-public class MybatisPlusConfig {
-
- /**
- * mybatis-plus分页插件
- * 文档:http://mp.baomidou.com
- */
- @Bean
- public PaginationInterceptor paginationInterceptor() {
- PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
- List sqlParserList = new ArrayList();
- // 攻击 SQL 阻断解析器、加入解析链
- sqlParserList.add(new BlockAttackSqlParser());
- paginationInterceptor.setSqlParserList(sqlParserList);
- return paginationInterceptor;
- }
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/SeataAutoConfig.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/SeataAutoConfig.java
deleted file mode 100644
index b5e68082b..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/config/SeataAutoConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.config;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import io.seata.spring.annotation.GlobalTransactionScanner;
-
-@Configuration
-public class SeataAutoConfig {
- private final static Logger logger = LoggerFactory.getLogger(SeataAutoConfig.class);
-
- /**
- * init global transaction scanner
- *
- * @Return: GlobalTransactionScanner
- */
- @Bean
- public GlobalTransactionScanner globalTransactionScanner() {
- logger.info("配置seata........");
- return new GlobalTransactionScanner("test-provider", "my_test_tx_group");
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/AccountMapper.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/AccountMapper.java
deleted file mode 100644
index 7ceca1d0a..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/AccountMapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-import io.seata.samples.entity.Account;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-public interface AccountMapper extends BaseMapper {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/OrdersMapper.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/OrdersMapper.java
deleted file mode 100644
index 40f2ecbe0..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/OrdersMapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-import io.seata.samples.entity.Orders;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-public interface OrdersMapper extends BaseMapper {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/ProductMapper.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/ProductMapper.java
deleted file mode 100644
index 3482fd338..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/mapper/ProductMapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-import io.seata.samples.entity.Product;
-
-/**
- * @author Funkye
- * @since 2019-12-07
- */
-public interface ProductMapper extends BaseMapper {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/AccountServiceImpl.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/AccountServiceImpl.java
deleted file mode 100644
index 8cb3a5c99..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/AccountServiceImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import io.seata.samples.service.IAccountService;
-import org.apache.dubbo.config.annotation.DubboService;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import io.seata.samples.entity.Account;
-import io.seata.samples.mapper.AccountMapper;
-
-@DubboService(version = "1.0.0", interfaceClass = IAccountService.class)
-@DS(value = "master_1")
-public class AccountServiceImpl extends ServiceImpl implements IAccountService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/OrdersServiceImpl.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/OrdersServiceImpl.java
deleted file mode 100644
index 5d5b76075..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/OrdersServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import io.seata.samples.service.IOrdersService;
-import io.seata.samples.service.IProductService;
-import org.apache.dubbo.config.annotation.DubboService;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import io.seata.samples.entity.Orders;
-import io.seata.samples.mapper.OrdersMapper;
-
-@DubboService(version = "1.0.0", interfaceClass = IOrdersService.class)
-@DS(value = "master_2")
-public class OrdersServiceImpl extends ServiceImpl implements IOrdersService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/ProductServiceImpl.java b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/ProductServiceImpl.java
deleted file mode 100644
index dfb76d627..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/java/io/seata/samples/service/impl/ProductServiceImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import io.seata.samples.service.IProductService;
-import org.apache.dubbo.config.annotation.DubboService;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import io.seata.samples.entity.Product;
-import io.seata.samples.mapper.ProductMapper;
-
-@DubboService(version = "1.0.0", interfaceClass = IProductService.class)
-@DS(value = "master_3")
-public class ProductServiceImpl extends ServiceImpl implements IProductService {
-
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/application.yml b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/application.yml
deleted file mode 100644
index 245e225fe..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/application.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-server:
- port: 38888
-spring:
- application:
- name: test-provider
- datasource:
- dynamic:
- seata: true
- primary: master_1
- datasource:
- master_1:
- url: jdbc:mysql://127.0.0.1:3306/test_pay?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
- driver-class-name: com.mysql.cj.jdbc.Driver
- username: root
- password: 123456
- master_2:
- url: jdbc:mysql://127.0.0.1:3306/test_order?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
- driver-class-name: com.mysql.cj.jdbc.Driver
- username: root
- password: 123456
- master_3:
- url: jdbc:mysql://127.0.0.1:3306/test_storage?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
- driver-class-name: com.mysql.cj.jdbc.Driver
- username: root
- password: 123456
-dubbo:
- protocol:
- loadbalance: leastactive
- threadpool: cached
- scan:
- base-packages: io.seata.samples.service
- application:
- qos-enable: false
- name: test-provider
- registry:
- id: my-registry
- address: nacos://127.0.0.1:8848
- group: SEATA_GROUP
-mybatis-plus:
- mapper-locations: classpath:/mapper/*Mapper.xml
- typeAliasesPackage: io.seata.samples.entity
- global-config:
- db-config:
- field-strategy: not-empty
- id-type: auto
- db-type: mysql
- configuration:
- map-underscore-to-camel-case: true
- cache-enabled: true
- auto-mapping-unknown-column-behavior: none
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/AccountMapper.xml b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/AccountMapper.xml
deleted file mode 100644
index 76b9e0fce..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/AccountMapper.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/OrdersMapper.xml b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/OrdersMapper.xml
deleted file mode 100644
index 916adb829..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/OrdersMapper.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/ProductMapper.xml b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/ProductMapper.xml
deleted file mode 100644
index af65a815c..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/mapper/ProductMapper.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/registry.conf b/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/registry.conf
deleted file mode 100644
index ad2c5f26f..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/provider/src/main/resources/registry.conf
+++ /dev/null
@@ -1,96 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- application = "seata-server"
- serverAddr = "127.0.0.1:8848"
- group = "SEATA_GROUP"
- namespace = ""
- cluster = "default"
- username = "nacos"
- password = "nacos"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = 0
- password = ""
- cluster = "default"
- timeout = 0
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- aclToken = ""
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
-
- nacos {
- serverAddr = "127.0.0.1:8848"
- namespace = ""
- group = "SEATA_GROUP"
- username = "nacos"
- password = "nacos"
- dataId = "nacos-server.properties"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- aclToken = ""
- }
- apollo {
- appId = "seata-server"
- ## apolloConfigService will cover apolloMeta
- apolloMeta = "http://192.168.1.204:8801"
- apolloConfigService = "http://192.168.1.204:8080"
- namespace = "application"
- apolloAccesskeySecret = ""
- cluster = "seata"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- nodePath = "/seata/seata.properties"
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/dubbo-multiple-datasource-mybatis-plus/sql/test_order.sql b/dubbo-multiple-datasource-mybatis-plus/sql/test_order.sql
deleted file mode 100644
index db38a5b2b..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/sql/test_order.sql
+++ /dev/null
@@ -1,32 +0,0 @@
--- test_order.orders definition
-
-CREATE TABLE `orders` (
- `id` int NOT NULL AUTO_INCREMENT,
- `product_id` int DEFAULT NULL,
- `amount` double(11,2) DEFAULT NULL,
- `sum` int DEFAULT NULL,
- `create_time` datetime DEFAULT NULL,
- `replace_time` datetime DEFAULT NULL,
- `account_id` int DEFAULT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
-INSERT INTO orders(product_id, amount, sum, create_time, replace_time, account_id)
-VALUES(0, 0, 0, '2022-01-01 01:01:00', '2022-01-01 01:01:00', 0);
-
-
--- test_order.undo_log definition
-
-CREATE TABLE `undo_log` (
- `id` bigint NOT NULL AUTO_INCREMENT,
- `branch_id` bigint NOT NULL,
- `xid` varchar(100) CHARACTER SET utf8 NOT NULL,
- `context` varchar(128) CHARACTER SET utf8 NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
\ No newline at end of file
diff --git a/dubbo-multiple-datasource-mybatis-plus/sql/test_pay.sql b/dubbo-multiple-datasource-mybatis-plus/sql/test_pay.sql
deleted file mode 100644
index aa74b6819..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/sql/test_pay.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- test_pay.account definition
-
-CREATE TABLE `account` (
- `id` int NOT NULL AUTO_INCREMENT,
- `user_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
- `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- `sum` int DEFAULT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
-INSERT INTO account (user_name, last_update_time, sum)
-VALUES('', CURRENT_TIMESTAMP, 0);
-
--- test_pay.undo_log definition
-
-CREATE TABLE `undo_log` (
- `id` bigint NOT NULL AUTO_INCREMENT,
- `branch_id` bigint NOT NULL,
- `xid` varchar(100) CHARACTER SET utf8 NOT NULL,
- `context` varchar(128) CHARACTER SET utf8 NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
\ No newline at end of file
diff --git a/dubbo-multiple-datasource-mybatis-plus/sql/test_storage.sql b/dubbo-multiple-datasource-mybatis-plus/sql/test_storage.sql
deleted file mode 100644
index 2c052101e..000000000
--- a/dubbo-multiple-datasource-mybatis-plus/sql/test_storage.sql
+++ /dev/null
@@ -1,26 +0,0 @@
--- test_storage.product definition
-
-CREATE TABLE `product` (
- `id` int NOT NULL AUTO_INCREMENT,
- `price` double DEFAULT NULL,
- `stock` int DEFAULT NULL,
- `last_update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
-
--- test_storage.undo_log definition
-
-CREATE TABLE `undo_log` (
- `id` bigint NOT NULL AUTO_INCREMENT,
- `branch_id` bigint NOT NULL,
- `xid` varchar(100) CHARACTER SET utf8 NOT NULL,
- `context` varchar(128) CHARACTER SET utf8 NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
\ No newline at end of file
diff --git a/dubbo/README.md b/dubbo/README.md
deleted file mode 100644
index 5f44825af..000000000
--- a/dubbo/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# dubbo
-
-How to use Seata to ensure consistency between Dubbo Microservices ?
-
-Please see the blog:
-Engligh: http://dubbo.apache.org/en-us/blog/dubbo-fescar.html
-中 文: http://dubbo.apache.org/zh-cn/blog/dubbo-fescar.html
-
-## Quick Start
-
-1. Startup Seata Server
-
-```shell script
-docker run --name seata-file -p 8091:8091 hellowoodes/seata:0.9.0-file
-```
-
-> You can also download seata [release](https://github.com/seata/seata/releases) version ,then run bin/seata-server .
-
-2. Startup Zookeeper
-
-```shell script
-docker run --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 -d zookeeper
-```
-
-3. Execute SQL under `seata-samples\dubbo\src\main\resources\sql`
-
-4. Run `DubboStockServiceStarter`,`DubboAccountServiceStarter`,`DubboOrderServiceStarter`,`DubboBusinessTester`
-
diff --git a/dubbo/pom.xml b/dubbo/pom.xml
deleted file mode 100644
index 2472e87b2..000000000
--- a/dubbo/pom.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
- io.seata
- seata-samples
- 1.1.0
-
- 4.0.0
- seata-samples-dubbo
- jar
- seata-samples-dubbo ${project.version}
-
-
- org.apache.dubbo
- dubbo
-
-
- io.seata
- seata-all
-
-
- com.101tec
- zkclient
-
-
- com.alibaba
- dubbo-registry-nacos
-
-
- com.alibaba.spring
- spring-context-support
-
-
- junit
- junit
- test
-
-
- jakarta.annotation
- jakarta.annotation-api
-
-
- org.springframework
- spring-jdbc
-
-
- mysql
- mysql-connector-java
-
-
- org.apache.curator
- curator-recipes
-
-
-
-
-
-
-
- com.google.guava
- guava
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
-
-
- org.apache.maven.plugins
- maven-deploy-plugin
- 2.8.2
-
- true
-
-
-
-
-
-
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/ApplicationKeeper.java b/dubbo/src/main/java/io/seata/samples/dubbo/ApplicationKeeper.java
deleted file mode 100644
index c59c9c4bf..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/ApplicationKeeper.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo;
-
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.support.AbstractApplicationContext;
-
-/**
- * The type Application keeper.
- */
-public class ApplicationKeeper {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationKeeper.class);
-
- private final ReentrantLock LOCK = new ReentrantLock();
- private final Condition STOP = LOCK.newCondition();
-
- /**
- * Instantiates a new Application keeper.
- *
- * @param applicationContext the application context
- */
- public ApplicationKeeper(AbstractApplicationContext applicationContext) {
- addShutdownHook(applicationContext);
- }
-
- private void addShutdownHook(final AbstractApplicationContext applicationContext) {
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- applicationContext.close();
- LOGGER.info("ApplicationContext " + applicationContext + " is closed.");
- } catch (Exception e) {
- LOGGER.error("Failed to close ApplicationContext", e);
- }
-
- LOCK.lock();
- try {
- STOP.signal();
- } finally {
- LOCK.unlock();
- }
- }
- }));
- }
-
- /**
- * Keep.
- */
- public void keep() {
- LOCK.lock();
- try {
- LOGGER.info("Application is keep running ... ");
- STOP.await();
- } catch (InterruptedException e) {
- LOGGER.error("ApplicationKeeper.keep() is interrupted by InterruptedException!", e);
- } finally {
- LOCK.unlock();
- }
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/Order.java b/dubbo/src/main/java/io/seata/samples/dubbo/Order.java
deleted file mode 100644
index 9e05541d2..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/Order.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo;
-
-import java.io.Serializable;
-
-/**
- * The type Order.
- */
-public class Order implements Serializable {
- /**
- * The Id.
- */
- public long id;
- /**
- * The User id.
- */
- public String userId;
- /**
- * The Commodity code.
- */
- public String commodityCode;
- /**
- * The Count.
- */
- public int count;
- /**
- * The Money.
- */
- public int money;
-
- @Override
- public String toString() {
- return "Order{" + "id=" + id + ", userId='" + userId + '\'' + ", commodityCode='" + commodityCode + '\''
- + ", count=" + count + ", money=" + money + '}';
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/AccountService.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/AccountService.java
deleted file mode 100644
index 9783fe7e4..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/AccountService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service;
-
-/**
- * The interface Account service.
- */
-public interface AccountService {
-
- /**
- * 余额扣款
- *
- * @param userId 用户ID
- * @param money 扣款金额
- */
- void debit(String userId, int money);
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/BusinessService.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/BusinessService.java
deleted file mode 100644
index eb3849dea..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/BusinessService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service;
-
-/**
- * The interface Business service.
- */
-public interface BusinessService {
-
- /**
- * 用户订购商品
- *
- * @param userId 用户ID
- * @param commodityCode 商品编号
- * @param orderCount 订购数量
- */
- void purchase(String userId, String commodityCode, int orderCount);
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/OrderService.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/OrderService.java
deleted file mode 100644
index 799d6b28e..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/OrderService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service;
-
-import io.seata.samples.dubbo.Order;
-
-/**
- * The interface Order service.
- */
-public interface OrderService {
- /**
- * 创建订单
- *
- * @param userId 用户ID
- * @param commodityCode 商品编号
- * @param orderCount 订购数量
- * @return 生成的订单 order
- */
- Order create(String userId, String commodityCode, int orderCount);
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/StockService.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/StockService.java
deleted file mode 100644
index e5a664393..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/StockService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service;
-
-/**
- * The interface Stock service.
- */
-public interface StockService {
-
- /**
- * 扣减库存
- *
- * @param commodityCode 商品编号
- * @param count 扣减数量
- */
- void deduct(String commodityCode, int count);
-
- /**
- * 批量扣减
- *
- * @param commodityCode
- * @param count
- */
- void batchDeduct(String commodityCode, int count);
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/AccountServiceImpl.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/AccountServiceImpl.java
deleted file mode 100644
index 70a47d6fe..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/AccountServiceImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service.impl;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.dubbo.service.AccountService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Please add the follow VM arguments:
- *
- * -Djava.net.preferIPv4Stack=true
- *
- */
-public class AccountServiceImpl implements AccountService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
-
- private JdbcTemplate jdbcTemplate;
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- @Override
- public void debit(String userId, int money) {
- LOGGER.info("Account Service ... xid: " + RootContext.getXID());
- LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
- userId);
-
- jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", new Object[] {money, userId});
- LOGGER.info("Account Service End ... ");
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/BusinessServiceImpl.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/BusinessServiceImpl.java
deleted file mode 100644
index 3f486e787..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/BusinessServiceImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service.impl;
-
-import java.util.Random;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.dubbo.service.BusinessService;
-import io.seata.samples.dubbo.service.OrderService;
-import io.seata.samples.dubbo.service.StockService;
-import io.seata.spring.annotation.GlobalTransactional;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Please add the follow VM arguments:
- *
- * -Djava.net.preferIPv4Stack=true
- *
- */
-public class BusinessServiceImpl implements BusinessService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
-
- private StockService stockService;
- private OrderService orderService;
- private Random random = new Random();
-
- @Override
- @GlobalTransactional(timeoutMills = 300000, name = "dubbo-demo-tx")
- public void purchase(String userId, String commodityCode, int orderCount) {
- LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
- stockService.deduct(commodityCode, orderCount);
- // just test batch update
- //stockService.batchDeduct(commodityCode, orderCount);
- orderService.create(userId, commodityCode, orderCount);
- if (random.nextBoolean()) {
- throw new RuntimeException("random exception mock!");
- }
-
- }
-
- /**
- * Sets stock service.
- *
- * @param stockService the stock service
- */
- public void setStockService(StockService stockService) {
- this.stockService = stockService;
- }
-
- /**
- * Sets order service.
- *
- * @param orderService the order service
- */
- public void setOrderService(OrderService orderService) {
- this.orderService = orderService;
- }
-
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/OrderServiceImpl.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/OrderServiceImpl.java
deleted file mode 100644
index 6229d8271..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/OrderServiceImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service.impl;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.dubbo.Order;
-import io.seata.samples.dubbo.service.AccountService;
-import io.seata.samples.dubbo.service.OrderService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.PreparedStatementCreator;
-import org.springframework.jdbc.support.GeneratedKeyHolder;
-import org.springframework.jdbc.support.KeyHolder;
-
-/**
- * Please add the follow VM arguments:
- *
- * -Djava.net.preferIPv4Stack=true
- *
- */
-public class OrderServiceImpl implements OrderService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
-
- private AccountService accountService;
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public Order create(String userId, String commodityCode, int orderCount) {
- LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
-
- // 计算订单金额
- int orderMoney = calculate(commodityCode, orderCount);
-
- // 从账户余额扣款
- accountService.debit(userId, orderMoney);
-
- final Order order = new Order();
- order.userId = userId;
- order.commodityCode = commodityCode;
- order.count = orderCount;
- order.money = orderMoney;
-
- KeyHolder keyHolder = new GeneratedKeyHolder();
-
- LOGGER.info(
- "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
- userId, commodityCode, orderCount, orderMoney);
-
- jdbcTemplate.update(new PreparedStatementCreator() {
-
- @Override
- public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
- PreparedStatement pst = con.prepareStatement(
- "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
- PreparedStatement.RETURN_GENERATED_KEYS);
- pst.setObject(1, order.userId);
- pst.setObject(2, order.commodityCode);
- pst.setObject(3, order.count);
- pst.setObject(4, order.money);
- return pst;
- }
- }, keyHolder);
-
- order.id = keyHolder.getKey().longValue();
-
- LOGGER.info("Order Service End ... Created " + order);
-
- return order;
- }
-
- /**
- * Sets account service.
- *
- * @param accountService the account service
- */
- public void setAccountService(AccountService accountService) {
- this.accountService = accountService;
- }
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- private int calculate(String commodityId, int orderCount) {
- return 200 * orderCount;
- }
-
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/StockServiceImpl.java b/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/StockServiceImpl.java
deleted file mode 100644
index dbe300dbb..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/service/impl/StockServiceImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.service.impl;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.dubbo.service.StockService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Please add the follow VM arguments:
- *
- * -Djava.net.preferIPv4Stack=true
- *
- */
-public class StockServiceImpl implements StockService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(StockService.class);
-
- private JdbcTemplate jdbcTemplate;
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- @Override
- public void deduct(String commodityCode, int count) {
- LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
- LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
- commodityCode);
-
- jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
- new Object[] {count, commodityCode});
- LOGGER.info("Stock Service End ... ");
-
- }
-
- @Override
- public void batchDeduct(String commodityCode, int count) {
- LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
- LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
- commodityCode);
-
- jdbcTemplate.batchUpdate(
- "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'",
- "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode + "'");
- LOGGER.info("Stock Service End ... ");
-
- }
-
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboAccountServiceStarter.java b/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboAccountServiceStarter.java
deleted file mode 100644
index 9289ca6f0..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboAccountServiceStarter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.starter;
-
-import io.seata.samples.dubbo.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Dubbo account service starter.
- */
-public class DubboAccountServiceStarter {
- /**
- * 2. Account service is ready . A buyer register an account: U100001 on my e-commerce platform
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- ClassPathXmlApplicationContext accountContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-account-service.xml"});
- accountContext.getBean("service");
- JdbcTemplate accountJdbcTemplate = (JdbcTemplate)accountContext.getBean("jdbcTemplate");
- accountJdbcTemplate.update("delete from account_tbl where user_id = 'U100001'");
- accountJdbcTemplate.update("insert into account_tbl(user_id, money) values ('U100001', 999)");
-
- new ApplicationKeeper(accountContext).keep();
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboBusinessTester.java b/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboBusinessTester.java
deleted file mode 100644
index 5f55126ab..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboBusinessTester.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.starter;
-
-import io.seata.samples.dubbo.service.BusinessService;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * The type Dubbo business tester.
- */
-public class DubboBusinessTester {
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- /**
- * 4. The whole e-commerce platform is ready , The buyer(U100001) create an order on the sku(C00321) , the
- * count is 2
- */
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-business.xml"});
- final BusinessService business = (BusinessService)context.getBean("business");
- business.purchase("U100001", "C00321", 2);
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboOrderServiceStarter.java b/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboOrderServiceStarter.java
deleted file mode 100644
index 045054906..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboOrderServiceStarter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.starter;
-
-import io.seata.samples.dubbo.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * The type Dubbo order service starter.
- */
-public class DubboOrderServiceStarter {
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- /**
- * 3. Order service is ready . Waiting for buyers to order
- */
- ClassPathXmlApplicationContext orderContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-order-service.xml"});
- orderContext.getBean("service");
- new ApplicationKeeper(orderContext).keep();
- }
-}
diff --git a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboStockServiceStarter.java b/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboStockServiceStarter.java
deleted file mode 100644
index 94093b710..000000000
--- a/dubbo/src/main/java/io/seata/samples/dubbo/starter/DubboStockServiceStarter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.dubbo.starter;
-
-import io.seata.samples.dubbo.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Dubbo stock service starter.
- */
-public class DubboStockServiceStarter {
- /**
- * 1. Stock service is ready . A seller add 100 stock to a sku: C00321
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- ClassPathXmlApplicationContext stockContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-stock-service.xml"});
- stockContext.getBean("service");
- JdbcTemplate stockJdbcTemplate = (JdbcTemplate)stockContext.getBean("jdbcTemplate");
- stockJdbcTemplate.update("delete from stock_tbl where commodity_code = 'C00321'");
- stockJdbcTemplate.update("insert into stock_tbl(commodity_code, count) values ('C00321', 100)");
- new ApplicationKeeper(stockContext).keep();
- }
-}
diff --git a/dubbo/src/main/resources/file.conf b/dubbo/src/main/resources/file.conf
deleted file mode 100644
index e38ee8290..000000000
--- a/dubbo/src/main/resources/file.conf
+++ /dev/null
@@ -1,66 +0,0 @@
-transport {
- # tcp udt unix-domain-socket
- type = "TCP"
- #NIO NATIVE
- server = "NIO"
- #enable heartbeat
- heartbeat = true
- # the client batch send request enable
- enableClientBatchSendRequest = true
- #thread factory for netty
- threadFactory {
- bossThreadPrefix = "NettyBoss"
- workerThreadPrefix = "NettyServerNIOWorker"
- serverExecutorThread-prefix = "NettyServerBizHandler"
- shareBossWorker = false
- clientSelectorThreadPrefix = "NettyClientSelector"
- clientSelectorThreadSize = 1
- clientWorkerThreadPrefix = "NettyClientWorkerThread"
- # netty boss thread size,will not be used for UDT
- bossThreadSize = 1
- #auto default pin or 8
- workerThreadSize = "default"
- }
- shutdown {
- # when destroy server, wait seconds
- wait = 3
- }
- serialization = "seata"
- compressor = "none"
-}
-service {
- #transaction service group mapping
- vgroupMapping.my_test_tx_group = "default"
- #only support when registry.type=file, please don't set multiple addresses
- default.grouplist = "127.0.0.1:8091"
- #degrade, current not support
- enableDegrade = false
- #disable seata
- disableGlobalTransaction = false
-}
-
-client {
- rm {
- asyncCommitBufferLimit = 10000
- lock {
- retryInterval = 10
- retryTimes = 30
- retryPolicyBranchRollbackOnConflict = true
- }
- reportRetryCount = 5
- tableMetaCheckEnable = false
- reportSuccessEnable = false
- }
- tm {
- commitRetryCount = 5
- rollbackRetryCount = 5
- }
- undo {
- dataValidation = true
- logSerialization = "jackson"
- logTable = "undo_log"
- }
- log {
- exceptionRate = 100
- }
-}
\ No newline at end of file
diff --git a/dubbo/src/main/resources/jdbc.properties b/dubbo/src/main/resources/jdbc.properties
deleted file mode 100644
index d01393190..000000000
--- a/dubbo/src/main/resources/jdbc.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright 1999-2018 Alibaba Group Holding Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-jdbc.account.url=jdbc:mysql://localhost:3306/seata
-jdbc.account.username=root
-jdbc.account.password=123456
-jdbc.account.driver=com.mysql.jdbc.Driver
-# stock db config
-jdbc.stock.url=jdbc:mysql://localhost:3306/seata
-jdbc.stock.username=root
-jdbc.stock.password=123456
-jdbc.stock.driver=com.mysql.jdbc.Driver
-# order db config
-jdbc.order.url=jdbc:mysql://localhost:3306/seata
-jdbc.order.username=root
-jdbc.order.password=123456
-jdbc.order.driver=com.mysql.jdbc.Driver
\ No newline at end of file
diff --git a/dubbo/src/main/resources/log4j.properties b/dubbo/src/main/resources/log4j.properties
deleted file mode 100644
index 78697f5fa..000000000
--- a/dubbo/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-log4j.rootLogger=info,stdout
-### output console ###
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
diff --git a/dubbo/src/main/resources/registry.conf b/dubbo/src/main/resources/registry.conf
deleted file mode 100644
index cd2b7ac33..000000000
--- a/dubbo/src/main/resources/registry.conf
+++ /dev/null
@@ -1,79 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "file"
-
- nacos {
- application = "seata-server"
- serverAddr = "localhost"
- namespace = ""
- username = ""
- password = ""
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = "0"
- password = ""
- timeout = "0"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
- type = "file"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- group = "SEATA_GROUP"
- username = ""
- password = ""
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- apollo {
- appId = "seata-server"
- apolloMeta = "http://192.168.1.204:8801"
- namespace = "application"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/dubbo/src/main/resources/spring/dubbo-account-service.xml b/dubbo/src/main/resources/spring/dubbo-account-service.xml
deleted file mode 100644
index a3cbbb348..000000000
--- a/dubbo/src/main/resources/spring/dubbo-account-service.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dubbo/src/main/resources/spring/dubbo-business.xml b/dubbo/src/main/resources/spring/dubbo-business.xml
deleted file mode 100644
index 7b45a3504..000000000
--- a/dubbo/src/main/resources/spring/dubbo-business.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dubbo/src/main/resources/spring/dubbo-order-service.xml b/dubbo/src/main/resources/spring/dubbo-order-service.xml
deleted file mode 100644
index 6082038c2..000000000
--- a/dubbo/src/main/resources/spring/dubbo-order-service.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dubbo/src/main/resources/spring/dubbo-stock-service.xml b/dubbo/src/main/resources/spring/dubbo-stock-service.xml
deleted file mode 100644
index 9038d471a..000000000
--- a/dubbo/src/main/resources/spring/dubbo-stock-service.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dubbo/src/main/resources/sql/dubbo_biz.sql b/dubbo/src/main/resources/sql/dubbo_biz.sql
deleted file mode 100644
index 3a97410c2..000000000
--- a/dubbo/src/main/resources/sql/dubbo_biz.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-DROP TABLE IF EXISTS `stock_tbl`;
-CREATE TABLE `stock_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`commodity_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `order_tbl`;
-CREATE TABLE `order_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `account_tbl`;
-CREATE TABLE `account_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/dubbo/src/main/resources/sql/undo_log.sql b/dubbo/src/main/resources/sql/undo_log.sql
deleted file mode 100644
index 8ee88ab1e..000000000
--- a/dubbo/src/main/resources/sql/undo_log.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
-CREATE TABLE `undo_log`
-(
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/etcd3/api-etcd3-samples/pom.xml b/etcd3/api-etcd3-samples/pom.xml
deleted file mode 100644
index 4d5b1d3f6..000000000
--- a/etcd3/api-etcd3-samples/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- etcd3
- io.seata
- 1.1.0
-
- 4.0.0
-
- api-etcd3-samples
-
-
-
- io.seata
- seata-all
-
-
- com.alibaba
- druid
-
-
- mysql
- mysql-connector-java
- ${mysql-connector.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
-
- io.etcd
- jetcd-core
-
-
-
-
-
\ No newline at end of file
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/Bussiness.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/Bussiness.java
deleted file mode 100644
index 229a351bb..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/Bussiness.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.rm.RMClient;
-import io.seata.samples.etcd3.api.service.AccountService;
-import io.seata.samples.etcd3.api.service.OrderService;
-import io.seata.samples.etcd3.api.service.StockService;
-import io.seata.samples.etcd3.api.service.impl.AccountServiceImpl;
-import io.seata.samples.etcd3.api.service.impl.OrderServiceImpl;
-import io.seata.samples.etcd3.api.service.impl.StockServiceImpl;
-import io.seata.tm.TMClient;
-import io.seata.tm.api.GlobalTransaction;
-import io.seata.tm.api.GlobalTransactionContext;
-
-import java.sql.SQLException;
-import java.util.concurrent.TimeUnit;
-
-
-
-/**
- * The type Bussiness.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class Bussiness {
-
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- * @throws SQLException the sql exception
- * @throws TransactionException the transaction exception
- */
- public static void main(String[] args) throws SQLException, TransactionException, InterruptedException {
-
- String userId = "U100001";
- String commodityCode = "C00321";
- int commodityCount = 100;
- int money = 999;
- AccountService accountService = new AccountServiceImpl();
- StockService stockService = new StockServiceImpl();
- OrderService orderService = new OrderServiceImpl();
- orderService.setAccountService(accountService);
-
- //reset data
- accountService.reset(userId, String.valueOf(money));
- stockService.reset(commodityCode, String.valueOf(commodityCount));
- orderService.reset(null, null);
-
- //init seata; only once
- String applicationId = "seata-server";
- String txServiceGroup = "default_tx_group";
- TMClient.init(applicationId, txServiceGroup);
- RMClient.init(applicationId, txServiceGroup);
-
- //trx
- GlobalTransaction tx = GlobalTransactionContext.getCurrentOrCreate();
- try {
- tx.begin(60000, "testBiz");
- System.out.println("begin trx, xid is " + tx.getXid());
-
- //biz operate 3 dataSources
- //set >=5 will be rollback(200*5>999) else will be commit
- int opCount = 5;
- stockService.deduct(commodityCode, opCount);
- orderService.create(userId, commodityCode, opCount);
-
- //check data if negative
- boolean needCommit = ((StockServiceImpl)stockService).validNegativeCheck("count", commodityCode)
- && ((AccountServiceImpl)accountService).validNegativeCheck("money", userId);
-
- //if data negative rollback else commit
- if (needCommit) {
- tx.commit();
- } else {
- System.out.println("rollback trx, cause: data negative, xid is " + tx.getXid());
- tx.rollback();
- }
- } catch (Exception exx) {
- System.out.println("rollback trx, cause: " + exx.getMessage() + " , xid is " + tx.getXid());
- tx.rollback();
- throw exx;
- }
- TimeUnit.SECONDS.sleep(3);
-
- }
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AbstractDataCheck.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AbstractDataCheck.java
deleted file mode 100644
index 1a7b9ad7c..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AbstractDataCheck.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The type Abstract data check.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public abstract class AbstractDataCheck {
-
- /**
- * Valid negative check boolean.
- *
- * @param field the field
- * @param id the id
- * @return the boolean
- */
- public boolean validNegativeCheck(String field, String id) throws SQLException {
- return doNegativeCheck(field, id) >= 0;
- }
-
- /**
- * Do negative check int.
- *
- * @param field the field
- * @param id the id
- * @return the int
- * @throws SQLException the sql exception
- */
- public abstract int doNegativeCheck(String field, String id) throws SQLException;
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AccountService.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AccountService.java
deleted file mode 100644
index 3c653fb9d..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/AccountService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Account service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public interface AccountService extends DataResetService {
- /**
- * Reduce.
- *
- * @param userId the user id
- * @param money the money
- * @throws SQLException the sql exception
- */
- void reduce(String userId, int money) throws SQLException;
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/DataResetService.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/DataResetService.java
deleted file mode 100644
index 3b9f515ea..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/DataResetService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Data reset service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public interface DataResetService {
- /**
- * Reset.
- *
- * @param key the key
- * @param value the value
- * @throws SQLException the sql exception
- */
- void reset(String key, String value) throws SQLException;
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/OrderService.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/OrderService.java
deleted file mode 100644
index 42eedc58a..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/OrderService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Order service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public interface OrderService extends DataResetService {
- /**
- * Sets account service.
- *
- * @param accountService the account service
- */
- void setAccountService(AccountService accountService);
-
- /**
- * Create.
- *
- * @param userId the user id
- * @param commodityCode the commodity code
- * @param count the count
- * @throws SQLException the sql exception
- */
- void create(String userId, String commodityCode, Integer count) throws SQLException;
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/StockService.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/StockService.java
deleted file mode 100644
index f88f3d2a5..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/StockService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service;
-
-import java.sql.SQLException;
-
-/**
- * The interface Stock service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public interface StockService extends DataResetService {
- /**
- * Deduct.
- *
- * @param commodityCode the commodity code
- * @param count the count
- * @throws SQLException the sql exception
- */
- void deduct(String commodityCode, int count) throws SQLException;
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/AccountServiceImpl.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/AccountServiceImpl.java
deleted file mode 100644
index 4d2e3676c..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/AccountServiceImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service.impl;
-
-import io.seata.samples.etcd3.api.service.AbstractDataCheck;
-import io.seata.samples.etcd3.api.service.AccountService;
-import io.seata.samples.etcd3.api.utils.DataSourceUtil;
-
-import java.sql.SQLException;
-
-
-
-/**
- * The type Account service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class AccountServiceImpl extends AbstractDataCheck implements AccountService {
-
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "account";
-
- @Override
- public void reduce(String userId, int money) throws SQLException {
- String sql = "update account_tbl set money = money - " + money + " where user_id = '" + userId + "'";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- }
-
- @Override
- public int doNegativeCheck(String field, String id) throws SQLException {
- String checkSql = "select " + field + " from account_tbl where user_id='" + id + "'";
- String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
- return Integer.parseInt(result);
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from account_tbl where user_id = '" + key + "'";
- String insertSql = "insert into account_tbl(user_id, money) values ('" + key + "', " + value + ")";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- DataSourceUtil.executeUpdate(DB_KEY, insertSql);
- }
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/OrderServiceImpl.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/OrderServiceImpl.java
deleted file mode 100644
index 9e1617b5b..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/OrderServiceImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service.impl;
-
-import io.seata.samples.etcd3.api.service.AccountService;
-import io.seata.samples.etcd3.api.service.OrderService;
-import io.seata.samples.etcd3.api.utils.DataSourceUtil;
-
-import java.sql.SQLException;
-
-
-
-/**
- * The type Order service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class OrderServiceImpl implements OrderService {
-
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "order";
- private AccountService accountService;
-
- @Override
- public void setAccountService(AccountService accountService) {
- this.accountService = accountService;
- }
-
- @Override
- public void create(String userId, String commodityCode, Integer count) throws SQLException {
- int money = count * 200;
- String sql = "insert into order_tbl (user_id, commodity_code, count, money) values ('" + userId + "','"
- + commodityCode + "'," + count + "," + money + ")";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- accountService.reduce(userId, money);
-
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from order_tbl";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- }
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/StockServiceImpl.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/StockServiceImpl.java
deleted file mode 100644
index 36431e70a..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/service/impl/StockServiceImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.service.impl;
-
-import io.seata.samples.etcd3.api.service.AbstractDataCheck;
-import io.seata.samples.etcd3.api.service.StockService;
-import io.seata.samples.etcd3.api.utils.DataSourceUtil;
-
-import java.sql.SQLException;
-
-
-
-/**
- * The type Stock service.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class StockServiceImpl extends AbstractDataCheck implements StockService {
- /**
- * The constant DB_KEY.
- */
- public static final String DB_KEY = "stock";
-
- @Override
- public void deduct(String commodityCode, int count) throws SQLException {
- String sql = "update stock_tbl set count = count - " + count + " where commodity_code = '" + commodityCode
- + "'";
- DataSourceUtil.executeUpdate(DB_KEY, sql);
- }
-
- @Override
- public void reset(String key, String value) throws SQLException {
- String deleteSql = "delete from stock_tbl where commodity_code = '" + key + "'";
- String insertSql = "insert into stock_tbl(commodity_code, count) values ('" + key + "', " + value + ")";
- DataSourceUtil.executeUpdate(DB_KEY, deleteSql);
- DataSourceUtil.executeUpdate(DB_KEY, insertSql);
- }
-
- @Override
- public int doNegativeCheck(String field, String id) throws SQLException {
- String checkSql = "select " + field + " from stock_tbl where commodity_code='" + id + "'";
- String result = DataSourceUtil.getSingleResult(DB_KEY, checkSql);
- return Integer.parseInt(result);
- }
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/DataSourceUtil.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/DataSourceUtil.java
deleted file mode 100644
index 4eda2b07a..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/DataSourceUtil.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.utils;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.sql.DataSource;
-
-import com.alibaba.druid.pool.DruidDataSource;
-
-import io.seata.rm.datasource.DataSourceProxy;
-
-/**
- * The type Data source util.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class DataSourceUtil {
-
- /**
- * The constant JDBC_PRO_PATH.
- */
- public static final String JDBC_PRO_PATH = "jdbc.properties";
- /**
- * The constant DATA_SOURCE_MAP.
- */
- public static final ConcurrentMap DATA_SOURCE_MAP = new ConcurrentHashMap<>();
-
- /**
- * Gets data source.
- *
- * @param name the name
- * @return the data source
- */
- public static DataSource getDataSource(String name) {
- String driverKey = "jdbc." + name + ".driver";
- String urlKey = "jdbc." + name + ".url";
- String userNameKey = "jdbc." + name + ".username";
- String pwdKey = "jdbc." + name + ".password";
- DataSource dataSource = new DruidDataSource();
- ((DruidDataSource)dataSource).setDriverClassName(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, driverKey));
- ((DruidDataSource)dataSource).setUrl(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, urlKey));
- ((DruidDataSource)dataSource).setUsername(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, userNameKey));
- ((DruidDataSource)dataSource).setPassword(PropertiesUtil.getPropertieValue(JDBC_PRO_PATH, pwdKey));
- return new DataSourceProxy(dataSource);
- }
-
- /**
- * Gets connection.
- *
- * @param name the name
- * @return the connection
- * @throws SQLException the sql exception
- */
- public static Connection getConnection(String name) throws SQLException {
- DATA_SOURCE_MAP.putIfAbsent(name, getDataSource(name));
- return DATA_SOURCE_MAP.get(name).getConnection();
- }
-
- /**
- * Execute update int.
- *
- * @param name the name
- * @param sql the sql
- * @return the int
- * @throws SQLException the sql exception
- */
- public static int executeUpdate(String name, String sql) throws SQLException {
- Connection connection = null;
- Statement statement = null;
- int result = 0;
- try {
- connection = getConnection(name);
- statement = connection.createStatement();
- result = statement.executeUpdate(sql);
-
- } catch (SQLException exx) {
- //todo
- throw exx;
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException exx) {
- }
- }
- return result;
- }
-
- /**
- * Gets single result.
- *
- * @param name the name
- * @param sql the sql
- * @return the single result
- * @throws SQLException the sql exception
- */
- public static String getSingleResult(String name, String sql) throws SQLException {
- Connection connection = null;
- Statement statement = null;
- String result = null;
- try {
- connection = getConnection(name);
- statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(sql);
- resultSet.next();
- result = resultSet.getString(1);
- } catch (SQLException exx) {
- //todo
- throw exx;
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException exx) {
- }
- }
- return result;
- }
-}
diff --git a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/PropertiesUtil.java b/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/PropertiesUtil.java
deleted file mode 100644
index 7383830d7..000000000
--- a/etcd3/api-etcd3-samples/src/main/java/io/seata/samples/etcd3/api/utils/PropertiesUtil.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.etcd3.api.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * The type Properties util.
- * @author xiaochangbai
- * @date 2022/1/15
- */
-public class PropertiesUtil {
-
- /**
- * Gets propertie value.
- *
- * @param path the path
- * @param key the key
- * @return the propertie value
- */
- public static String getPropertieValue(String path, String key) {
- return getPropertieValue(path, key, null);
-
- }
-
- /**
- * Gets propertie value.
- *
- * @param path the path
- * @param key the key
- * @param defaultValue the default value
- * @return the propertie value
- */
- public static String getPropertieValue(String path, String key, String defaultValue) {
- Properties properties = new Properties();
- InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream(path);
- try {
- properties.load(in);
- } catch (IOException ignore) {
- }
- String value = properties.getProperty(key);
- return value == null ? defaultValue : value;
- }
-}
-
diff --git a/etcd3/api-etcd3-samples/src/main/resources/all.sql b/etcd3/api-etcd3-samples/src/main/resources/all.sql
deleted file mode 100644
index b6ae6fb9f..000000000
--- a/etcd3/api-etcd3-samples/src/main/resources/all.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-CREATE TABLE `account_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `stock_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT '0',
- PRIMARY KEY (`id`),
- UNIQUE KEY `commodity_code` (`commodity_code`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `order_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT '0',
- `money` int(11) DEFAULT '0',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `undo_log`
-(
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/etcd3/api-etcd3-samples/src/main/resources/file.conf b/etcd3/api-etcd3-samples/src/main/resources/file.conf
deleted file mode 100644
index c960c460a..000000000
--- a/etcd3/api-etcd3-samples/src/main/resources/file.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-service {
- #vgroup->rgroup
- vgroupMapping.my_test_tx_group = "default"
- #only support single node
- default.grouplist = "127.0.0.1:8091"
- #degrade current not support
- enableDegrade = false
- #disable
- disable = false
-}
diff --git a/etcd3/api-etcd3-samples/src/main/resources/jdbc.properties b/etcd3/api-etcd3-samples/src/main/resources/jdbc.properties
deleted file mode 100644
index 4ed60813a..000000000
--- a/etcd3/api-etcd3-samples/src/main/resources/jdbc.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-jdbc.account.url=jdbc:mysql://localhost:3306/seata?useSSL=false&serverTimezone=UTC
-jdbc.account.username=root
-jdbc.account.password=root
-jdbc.account.driver=com.mysql.jdbc.Driver
-# stock db config
-jdbc.stock.url=jdbc:mysql://localhost:3306/seata?useSSL=false&serverTimezone=UTC
-jdbc.stock.username=root
-jdbc.stock.password=root
-jdbc.stock.driver=com.mysql.jdbc.Driver
-# order db config
-jdbc.order.url=jdbc:mysql://localhost:3306/seata?useSSL=false&serverTimezone=UTC
-jdbc.order.username=root
-jdbc.order.password=root
-jdbc.order.driver=com.mysql.jdbc.Driver
\ No newline at end of file
diff --git a/etcd3/api-etcd3-samples/src/main/resources/registry.conf b/etcd3/api-etcd3-samples/src/main/resources/registry.conf
deleted file mode 100644
index 25d405926..000000000
--- a/etcd3/api-etcd3-samples/src/main/resources/registry.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "etcd3"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- cluster = "default"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = "0"
- password = ""
- cluster = "default"
- timeout = "0"
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
- type = "etcd3"
-
- nacos {
- serverAddr = "localhost"
- namespace = ""
- group = "SEATA_GROUP"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- }
- apollo {
- app.id = "seata-server"
- apollo.meta = "http://192.168.1.204:8801"
- namespace = "application"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- session.timeout = 6000
- connect.timeout = 2000
- username = ""
- password = ""
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/etcd3/pom.xml b/etcd3/pom.xml
deleted file mode 100644
index f3d67e0ec..000000000
--- a/etcd3/pom.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- seata-samples
- io.seata
- 1.1.0
-
- 4.0.0
- pom
-
- api-etcd3-samples
-
- etcd3
-
-
- 0.3.0
-
-
-
-
-
- io.etcd
- jetcd-core
- ${jetcd.client.version}
-
-
-
-
-
\ No newline at end of file
diff --git a/ha/Readme.md b/ha/Readme.md
deleted file mode 100644
index f6adfad01..000000000
--- a/ha/Readme.md
+++ /dev/null
@@ -1,421 +0,0 @@
-# 基于 Seata 解决微服务架构下数据一致性的实践
-
-[Seata](https://github.com/seata/seata) 是一款开源的分布式事务解决方案,提供高性能和简单易用的分布式事务服务。
-
-本文将通过一个简单的微服务架构的例子,说明业务如何step by step的使用 Seata、Dubbo 来保证业务数据的一致性;
-
-本案例中,seata-server 服务端 使用数据库作为事务日志存储,用户可以部署多个seata-server以提供集群服务,从而支持服务端高可用。
-
-## 业务案例
-
-用户采购商品业务,整个业务包含3个微服务:
-
-- 库存服务: 扣减给定商品的库存数量。
-- 订单服务: 根据采购请求生成订单。
-- 账户服务: 用户账户金额扣减。
-
-### 业务结构图
-
-
-
-#### StockService
-
-```java
-public interface StockService {
- /**
- * deduct stock count
- */
- void deduct(String commodityCode, int count);
-}
-```
-
-#### OrderService
-
-```java
-public interface OrderService {
- /**
- * create order
- */
- Order create(String userId, String commodityCode, int orderCount);
-}
-```
-
-#### AccountService
-
-```java
-public interface AccountService {
- /**
- * debit balance of user's account
- */
- void debit(String userId, int money);
-}
-```
-
-**说明:** 以上三个微服务独立部署。
-
-### Seata、Dubbo 集成
-
-#### Step 1 初始化 MySQL 数据库(需要InnoDB 存储引擎)
-
-在 [resources/jdbc.properties](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/jdbc. properties)
-修改StockService、OrderService、AccountService 对应的连接信息。
-
-```properties
-jdbc.account.url=jdbc:mysql://xxxx/xxxx
-jdbc.account.username=xxxx
-jdbc.account.password=xxxx
-jdbc.account.driver=com.mysql.jdbc.Driver
-# stock db config
-jdbc.stock.url=jdbc:mysql://xxxx/xxxx
-jdbc.stock.username=xxxx
-jdbc.stock.password=xxxx
-jdbc.stock.driver=com.mysql.jdbc.Driver
-# order db config
-jdbc.order.url=jdbc:mysql://xxxx/xxxx
-jdbc.order.username=xxxx
-jdbc.order.password=xxxx
-jdbc.order.driver=com.mysql.jdbc.Driver
-```
-
-#### Step 2 创建 undo_log(用于 Seata AT 模式)表和相关业务表
-
-相关建表脚本可在 [resources/sql/](https://github.com/seata/seata-samples/tree/master/ha/src/main/resources/sql)
-下获取,在相应数据库中执行 [dubbo_biz.sql](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/sql/dubbo_biz.sql)
-中的业务建表脚本,在每个数据库执行 [undo_log.sql](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/sql/undo_log.sql)
-建表脚本。
-
-```sql
--- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
-CREATE TABLE `undo_log` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- `ext` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-```
-
-```sql
-DROP TABLE IF EXISTS `stock_tbl`;
-CREATE TABLE `stock_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`commodity_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `order_tbl`;
-CREATE TABLE `order_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `account_tbl`;
-CREATE TABLE `account_tbl` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-```
-
-**说明:** 需要保证每个物理库都包含 undo_log 表,此处可使用一个物理库来表示上述三个微服务对应的独立逻辑库。
-
-#### Step 3 引入 Seata、Dubbo 相关 POM 依赖
-
-```xml
-
- x.x.x
- 2.6.5
-
-
-
- io.seata
- seata-all
- ${seata.version}
-
-
-
- com.alibaba
- dubbo
- ${dubbo.alibaba.version}
-
-
-```
-
-#### Step 4 微服务 Provider Spring配置
-
-分别在三个微服务Spring配置文件([dubbo-account-service.xml](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/spring/dubbo-account-service.xml)、
-[dubbo-order-service](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/spring/dubbo-order-service.xml)
-和
-[dubbo-stock-service.xml](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/spring/dubbo-stock-service.xml)
-)进行如下配置:
-
-- 配置 Seata 代理数据源
-
-```xml
-
-
-
-
-
-
-
-```
-
-此处需要使用 io.seata.rm.datasource.DataSourceProxy 包装 Druid 数据源作为直接业务数据源,DataSourceProxy 用于业务 sql 的拦截解析并与 TC 交互协调事务操作状态。
-
-- 配置 Dubbo 注册中心
-
-```xml
-
-```
-
-- 配置 Seata GlobalTransactionScanner
-
-```xml
-
-
-
-
-```
-
-此处构造方法的第一个参数为业务自定义 applicationId,若在单机部署多微服务需要保证 applicationId 唯一。
-构造方法的第二个参数为 Seata 事务服务逻辑分组,此分组通过配置中心配置项 service.vgroup_mapping.my_test_tx_group 映射到相应的 Seata-Server
-集群名称,然后再根据集群名称.grouplist 获取到可用服务列表。
-
-#### Step 5 事务发起方配置
-
-在 [dubbo-business.xml](https://github.com/seata/seata-samples/blob/master/ha/src/main/resources/spring/dubbo-business.xml)
-配置以下配置:
-
-- 配置 Dubbo 注册中心
-
-同 Step 4
-
-- 配置 Seata GlobalTransactionScanner
-
-同 Step 4
-
-- 在事务发起方 service 方法上添加 @GlobalTransactional 注解
-
-```java
-@GlobalTransactional(timeoutMills = 300000, name = "dubbo-demo-tx")
-```
-
-timeoutMills 为事务的总体超时时间默认60s,name 为事务方法签名的别名,默认为空。注解内参数均可省略。
-
-#### Step 6 启动 Zookeeper
-
-本地以单机模式启动 zookeeper-server;
-
-#### Step 7 启动 Seata-Server
-
-配置 Seata-Server的数据库,启动Seata-Server ;
-
-- 下载 Seata-Server 最新 [release](https://github.com/seata/seata/releases) 包并解压
-
-- 准备 Seata-Server的数据库:
-
-安装mysql,创建数据库 seata_server : "create database seata_server;"
-
-创建 事务记录表,建表语句 [db_store.sql](https://github.com/seata/seata/blob/develop/server/src/main/resources/db_store.sql) :
-
-```sql
--- the table to store GlobalSession data
-drop table `global_table`;
-create table `global_table` (
- `xid` varchar(128) not null,
- `transaction_id` bigint,
- `status` tinyint not null,
- `application_id` varchar(64),
- `transaction_service_group` varchar(64),
- `transaction_name` varchar(128),
- `timeout` int,
- `begin_time` bigint,
- `application_data` varchar(2000),
- `gmt_create` datetime,
- `gmt_modified` datetime,
- primary key (`xid`),
- key `idx_gmt_modified_status` (`gmt_modified`, `status`),
- key `idx_transaction_id` (`transaction_id`)
-);
-
--- the table to store BranchSession data
-drop table `branch_table`;
-create table `branch_table` (
- `branch_id` bigint not null,
- `xid` varchar(128) not null,
- `transaction_id` bigint ,
- `resource_group_id` varchar(128),
- `resource_id` varchar(256) ,
- `lock_key` varchar(256) ,
- `branch_type` varchar(8) ,
- `status` tinyint,
- `client_id` varchar(64),
- `application_data` varchar(2000),
- `gmt_create` datetime,
- `gmt_modified` datetime,
- primary key (`branch_id`),
- key `idx_xid` (`xid`)
-);
-
--- the table to store lock data
-drop table `lock_table`;
-create table `lock_table` (
- `row_key` varchar(128) not null,
- `xid` varchar(128),
- `transaction_id` long ,
- `branch_id` long,
- `resource_id` varchar(256) ,
- `table_name` varchar(64) ,
- `pk` varchar(128) ,
- `gmt_create` datetime ,
- `gmt_modified` datetime,
- primary key(`row_key`)
-);
-
-```
-
-- 初始化 Seata 配置
-
-进入到 Seata-Server 解压目录 conf
-文件夹下 [file.conf](https://github.com/seata/seata/blob/develop/server/src/main/resources/file.conf) ,修改事务日志存储相关属性:
-
-修改项如下:
-
-```
-store.mode = "db"
-store.db.datasource=dbcp
-store.db.db-type=mysql
-store.db.driver-class-name=com.mysql.jdbc.Driver
-store.db.url=jdbc:mysql://127.0.0.1:3306/seata_server?useUnicode=true
-store.db.user=mysql
-store.db.password=mysql
-lock.mode=db
-
-```
-
-修改后 file.conf 中 store和lock 节点内容如下:
-
-```properties
-## transaction log store
-store {
- ## store mode: file、db
- mode = "db"
-
- ## file store
- file {
- dir = "sessionStore"
-
- # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
- max-branch-session-size = 16384
- # globe session size , if exceeded throws exceptions
- max-global-session-size = 512
- # file buffer size , if exceeded allocate new buffer
- file-write-buffer-cache-size = 16384
- # when recover batch read size
- session.reload.read_size = 100
- # async, sync
- flush-disk-mode = async
- }
-
- ## database store
- db {
- ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
- datasource = "dbcp"
- ## mysql/oracle/h2/oceanbase etc.
- db-type = "mysql"
- driver-class-name = com.mysql.jdbc.Driver
- url = "jdbc:mysql://127.0.0.1:3306/seata_server"
- user = "mysql"
- password = "mysql"
- min-conn = 1
- max-conn = 3
- global.table = "global_table"
- branch.table = "branch_table"
- query-limit = 100
- }
-}
-lock {
- ## the data row lock store mode: local_db、memory or db
- mode = "db"
-
- memory{
- ## store lock in memory of server
- }
-
- db{
- ## use db of server to store lock, the db is ${store.db.url}
- lock-table= "lock_table"
- }
-
-}
-
-
-```
-
-- 运行 Seata-server
-
-**Linux/Unix/Mac**
-
-```bash
-sh seata-server.sh $LISTEN_PORT $STORE_MODE $IP(此参数可选)
-```
-
-**Windows**
-
-```bash
-cmd seata-server.bat $LISTEN_PORT $PATH_FOR_PERSISTENT_DATA $IP(此参数可选)
-
-```
-
-**$LISTEN_PORT**: Seata-Server 服务端口
-**$STORE_MODE**: 事务操作记录存储模式:file、db
-**$IP(可选参数)**: 用于多 IP 环境下指定 Seata-Server 注册服务的IP
-
-**eg**:
-sh seata-server.sh 8091 db
-
-#### Step 8 启动微服务并测试
-
-- 修改业务客户端发现注册方式为 zookeeper
- 同Step 7 中[修改 Seata-server 服务注册方式为 zookeeper] 步骤
--
-
-启动 [DubboAccountServiceStarter](https://github.com/seata/seata-samples/blob/master/ha/src/main/java/io/seata/samples/ha/starter/DubboAccountServiceStarter.java)
--
-启动 [DubboOrderServiceStarter](https://github.com/seata/seata-samples/blob/master/ha/src/main/java/io/seata/samples/ha/starter/DubboOrderServiceStarter.java)
--
-启动 [DubboStockServiceStarter](https://github.com/seata/seata-samples/blob/master/ha/src/main/java/io/seata/samples/ha/starter/DubboStockServiceStarter.java)
-
--
-
-启动 [DubboBusinessTester](https://github.com/seata/seata-samples/blob/master/ha/src/main/java/io/seata/samples/ha/starter/DubboBusinessTester.java)
-进行测试
-
-**注意:** 在标注 @GlobalTransactional 注解方法内部显示的抛出异常才会进行事务的回滚。整个 Dubbo 服务调用链路只需要在事务最开始发起方的 service 方法标注注解即可。
-
-## 相关链接:
-
-本文 sample 地址: https://github.com/seata/seata-samples/tree/master/ha
-Seata: https://github.com/seata/seata
-Dubbo: https://github.com/apache/incubator-dubbo
-
-
-
-
-
diff --git a/ha/pom.xml b/ha/pom.xml
deleted file mode 100644
index a8fdf68ec..000000000
--- a/ha/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
-
-
- io.seata
- seata-samples
- 1.1.0
-
- 4.0.0
- seata-samples-HA
- seata-samples-HA ${project.version}
-
-
- 2.7.14
- 0.0.2
-
-
-
-
-
- io.seata
- seata-all
- ${seata.version}
-
-
-
- org.apache.dubbo
- dubbo
- ${dubbo.version}
-
-
- com.alibaba.nacos
- nacos-client
- 1.1.4
-
-
- org.apache.dubbo
- dubbo-registry-nacos
- ${dubbo.version}
-
-
- com.alibaba.spring
- spring-context-support
-
-
- com.101tec
- zkclient
-
-
- slf4j-log4j12
- org.slf4j
-
-
- log4j
- log4j
-
-
-
-
- junit
- junit
- test
-
-
- mysql
- mysql-connector-java
-
-
- org.springframework
- spring-jdbc
-
-
- ch.qos.logback
- logback-classic
-
-
- org.apache.curator
- curator-recipes
-
-
-
-
-
-
- mysql
- mysql-connector-java
- 8.0.28
-
-
-
- com.alibaba.spring
- spring-context-support
- 1.0.11
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-deploy-plugin
- 2.8.2
-
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/ha/src/main/java/io/seata/samples/nacos/ApplicationKeeper.java b/ha/src/main/java/io/seata/samples/nacos/ApplicationKeeper.java
deleted file mode 100644
index a45e71416..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/ApplicationKeeper.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos;
-
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.support.AbstractApplicationContext;
-
-/**
- * The type Application keeper.
- */
-public class ApplicationKeeper {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationKeeper.class);
-
- private final ReentrantLock LOCK = new ReentrantLock();
- private final Condition STOP = LOCK.newCondition();
-
- /**
- * Instantiates a new Application keeper.
- *
- * @param applicationContext the application context
- */
- public ApplicationKeeper(AbstractApplicationContext applicationContext) {
- addShutdownHook(applicationContext);
- }
-
- private void addShutdownHook(final AbstractApplicationContext applicationContext) {
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- applicationContext.close();
- LOGGER.info("ApplicationContext " + applicationContext + " is closed.");
- } catch (Exception e) {
- LOGGER.error("Failed to close ApplicationContext", e);
- }
-
- try {
- LOCK.lock();
- STOP.signal();
- } finally {
- LOCK.unlock();
- }
- }
- }));
- }
-
- /**
- * Keep.
- */
- public void keep() {
- synchronized (LOCK) {
- try {
- LOGGER.info("Application is keep running ... ");
- LOCK.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/Order.java b/ha/src/main/java/io/seata/samples/nacos/Order.java
deleted file mode 100644
index 348692134..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/Order.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos;
-
-import java.io.Serializable;
-
-/**
- * The type Order.
- */
-public class Order implements Serializable {
- /**
- * The Id.
- */
- public long id;
- /**
- * The User id.
- */
- public String userId;
- /**
- * The Commodity code.
- */
- public String commodityCode;
- /**
- * The Count.
- */
- public int count;
- /**
- * The Money.
- */
- public int money;
-
- @Override
- public String toString() {
- return "Order{" + "id=" + id + ", userId='" + userId + '\'' + ", commodityCode='" + commodityCode + '\''
- + ", count=" + count + ", money=" + money + '}';
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/AccountService.java b/ha/src/main/java/io/seata/samples/nacos/service/AccountService.java
deleted file mode 100644
index a2d0217c5..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/AccountService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service;
-
-/**
- * The interface Account service.
- */
-public interface AccountService {
-
- /**
- * 余额扣款
- *
- * @param userId 用户ID
- * @param money 扣款金额
- */
- void debit(String userId, int money);
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/BusinessService.java b/ha/src/main/java/io/seata/samples/nacos/service/BusinessService.java
deleted file mode 100644
index 248405eaf..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/BusinessService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service;
-
-/**
- * The interface Business service.
- */
-public interface BusinessService {
-
- /**
- * 用户订购商品
- *
- * @param userId 用户ID
- * @param commodityCode 商品编号
- * @param orderCount 订购数量
- */
- void purchase(String userId, String commodityCode, int orderCount);
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/OrderService.java b/ha/src/main/java/io/seata/samples/nacos/service/OrderService.java
deleted file mode 100644
index a5491859a..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/OrderService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service;
-
-import io.seata.samples.nacos.Order;
-
-/**
- * The interface Order service.
- */
-public interface OrderService {
- /**
- * 创建订单
- *
- * @param userId 用户ID
- * @param commodityCode 商品编号
- * @param orderCount 订购数量
- * @return 生成的订单 order
- */
- Order create(String userId, String commodityCode, int orderCount);
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/StockService.java b/ha/src/main/java/io/seata/samples/nacos/service/StockService.java
deleted file mode 100644
index c1d98e889..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/StockService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service;
-
-/**
- * The interface Stock service.
- */
-public interface StockService {
-
- /**
- * 扣减库存
- *
- * @param commodityCode 商品编号
- * @param count 扣减数量
- */
- void deduct(String commodityCode, int count);
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/impl/AccountServiceImpl.java b/ha/src/main/java/io/seata/samples/nacos/service/impl/AccountServiceImpl.java
deleted file mode 100644
index 2c7ac1555..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/impl/AccountServiceImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service.impl;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.nacos.service.AccountService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Account service.
- *
- * @author jimin.jm @alibaba-inc.com
- */
-public class AccountServiceImpl implements AccountService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(AccountService.class);
-
- private JdbcTemplate jdbcTemplate;
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- @Override
- public void debit(String userId, int money) {
- LOGGER.info("Account Service ... xid: " + RootContext.getXID());
- LOGGER.info("Deducting balance SQL: update account_tbl set money = money - {} where user_id = {}", money,
- userId);
-
- jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", new Object[] {money, userId});
- LOGGER.info("Account Service End ... ");
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/impl/BusinessServiceImpl.java b/ha/src/main/java/io/seata/samples/nacos/service/impl/BusinessServiceImpl.java
deleted file mode 100644
index f351d72f5..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/impl/BusinessServiceImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service.impl;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.nacos.service.BusinessService;
-import io.seata.samples.nacos.service.OrderService;
-import io.seata.samples.nacos.service.StockService;
-import io.seata.spring.annotation.GlobalTransactional;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The type Business service.
- *
- * @author jimin.jm @alibaba-inc.com
- */
-public class BusinessServiceImpl implements BusinessService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(BusinessService.class);
-
- private StockService stockService;
- private OrderService orderService;
-
- @Override
- @GlobalTransactional(timeoutMills = 300000, name = "dubbo-demo-tx")
- public void purchase(String userId, String commodityCode, int orderCount) {
- LOGGER.info("purchase begin ... xid: " + RootContext.getXID());
- stockService.deduct(commodityCode, orderCount);
- orderService.create(userId, commodityCode, orderCount);
- throw new RuntimeException("xxx");
-
- }
-
- /**
- * Sets stock service.
- *
- * @param stockService the stock service
- */
- public void setStockService(StockService stockService) {
- this.stockService = stockService;
- }
-
- /**
- * Sets order service.
- *
- * @param orderService the order service
- */
- public void setOrderService(OrderService orderService) {
- this.orderService = orderService;
- }
-
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/impl/OrderServiceImpl.java b/ha/src/main/java/io/seata/samples/nacos/service/impl/OrderServiceImpl.java
deleted file mode 100644
index 95722c5af..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/impl/OrderServiceImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service.impl;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.nacos.Order;
-import io.seata.samples.nacos.service.AccountService;
-import io.seata.samples.nacos.service.OrderService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.PreparedStatementCreator;
-import org.springframework.jdbc.support.GeneratedKeyHolder;
-import org.springframework.jdbc.support.KeyHolder;
-
-/**
- * The type Order service.
- *
- * @author jimin.jm @alibaba-inc.com
- */
-public class OrderServiceImpl implements OrderService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(OrderService.class);
-
- private AccountService accountService;
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public Order create(String userId, String commodityCode, int orderCount) {
- LOGGER.info("Order Service Begin ... xid: " + RootContext.getXID());
-
- // 计算订单金额
- int orderMoney = calculate(commodityCode, orderCount);
-
- // 从账户余额扣款
- accountService.debit(userId, orderMoney);
-
- final Order order = new Order();
- order.userId = userId;
- order.commodityCode = commodityCode;
- order.count = orderCount;
- order.money = orderMoney;
-
- KeyHolder keyHolder = new GeneratedKeyHolder();
-
- LOGGER.info(
- "Order Service SQL: insert into order_tbl (user_id, commodity_code, count, money) values ({}, {}, {}, {})",
- userId, commodityCode, orderCount, orderMoney);
-
- jdbcTemplate.update(new PreparedStatementCreator() {
-
- @Override
- public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
- PreparedStatement pst = con.prepareStatement(
- "insert into order_tbl (user_id, commodity_code, count, money) values (?, ?, ?, ?)",
- PreparedStatement.RETURN_GENERATED_KEYS);
- pst.setObject(1, order.userId);
- pst.setObject(2, order.commodityCode);
- pst.setObject(3, order.count);
- pst.setObject(4, order.money);
- return pst;
- }
- }, keyHolder);
-
- order.id = keyHolder.getKey().longValue();
-
- LOGGER.info("Order Service End ... Created " + order);
-
- return order;
- }
-
- /**
- * Sets account service.
- *
- * @param accountService the account service
- */
- public void setAccountService(AccountService accountService) {
- this.accountService = accountService;
- }
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- private int calculate(String commodityId, int orderCount) {
- return 200 * orderCount;
- }
-
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/service/impl/StockServiceImpl.java b/ha/src/main/java/io/seata/samples/nacos/service/impl/StockServiceImpl.java
deleted file mode 100644
index 19145846a..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/service/impl/StockServiceImpl.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.service.impl;
-
-import io.seata.core.context.RootContext;
-import io.seata.samples.nacos.service.StockService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Stock service.
- *
- * @author jimin.jm @alibaba-inc.com
- */
-public class StockServiceImpl implements StockService {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(StockService.class);
-
- private JdbcTemplate jdbcTemplate;
-
- /**
- * Sets jdbc template.
- *
- * @param jdbcTemplate the jdbc template
- */
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- @Override
- public void deduct(String commodityCode, int count) {
- LOGGER.info("Stock Service Begin ... xid: " + RootContext.getXID());
- LOGGER.info("Deducting inventory SQL: update stock_tbl set count = count - {} where commodity_code = {}", count,
- commodityCode);
-
- jdbcTemplate.update("update stock_tbl set count = count - ? where commodity_code = ?",
- new Object[] {count, commodityCode});
- LOGGER.info("Stock Service End ... ");
-
- }
-
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/starter/DubboAccountServiceStarter.java b/ha/src/main/java/io/seata/samples/nacos/starter/DubboAccountServiceStarter.java
deleted file mode 100644
index 887b497c6..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/starter/DubboAccountServiceStarter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.starter;
-
-import io.seata.samples.nacos.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Dubbo account service starter.
- */
-public class DubboAccountServiceStarter {
- /**
- * 2. Account service is ready . A buyer register an account: U100001 on my e-commerce platform
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- ClassPathXmlApplicationContext accountContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-account-service.xml"});
- accountContext.getBean("service");
- JdbcTemplate accountJdbcTemplate = (JdbcTemplate)accountContext.getBean("jdbcTemplate");
- accountJdbcTemplate.update("delete from account_tbl where user_id = 'U100001'");
- accountJdbcTemplate.update("insert into account_tbl(user_id, money) values ('U100001', 999)");
-
- new ApplicationKeeper(accountContext).keep();
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/starter/DubboBusinessTester.java b/ha/src/main/java/io/seata/samples/nacos/starter/DubboBusinessTester.java
deleted file mode 100644
index c61eed6db..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/starter/DubboBusinessTester.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.starter;
-
-import io.seata.samples.nacos.service.BusinessService;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * The type Dubbo business tester.
- */
-public class DubboBusinessTester {
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- /**
- * 4. The whole e-commerce platform is ready , The buyer(U100001) create an order on the sku(C00321) , the
- * count is 2
- */
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-business.xml"});
- //
-
- final BusinessService business = (BusinessService)context.getBean("business");
- business.purchase("U100001", "C00321", 2);
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/starter/DubboOrderServiceStarter.java b/ha/src/main/java/io/seata/samples/nacos/starter/DubboOrderServiceStarter.java
deleted file mode 100644
index c3f86163f..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/starter/DubboOrderServiceStarter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.starter;
-
-import io.seata.samples.nacos.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- * The type Dubbo order service starter.
- */
-public class DubboOrderServiceStarter {
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- /**
- * 3. Order service is ready . Waiting for buyers to order
- */
- ClassPathXmlApplicationContext orderContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-order-service.xml"});
- orderContext.getBean("service");
- new ApplicationKeeper(orderContext).keep();
- }
-}
diff --git a/ha/src/main/java/io/seata/samples/nacos/starter/DubboStockServiceStarter.java b/ha/src/main/java/io/seata/samples/nacos/starter/DubboStockServiceStarter.java
deleted file mode 100644
index 3f39d59ff..000000000
--- a/ha/src/main/java/io/seata/samples/nacos/starter/DubboStockServiceStarter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.samples.nacos.starter;
-
-import io.seata.samples.nacos.ApplicationKeeper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * The type Dubbo stock service starter.
- */
-public class DubboStockServiceStarter {
- /**
- * 1. Stock service is ready . A seller add 100 stock to a sku: C00321
- *
- * @param args the input arguments
- */
- public static void main(String[] args) {
- ClassPathXmlApplicationContext stockContext = new ClassPathXmlApplicationContext(
- new String[] {"spring/dubbo-stock-service.xml"});
- stockContext.getBean("service");
- JdbcTemplate stockJdbcTemplate = (JdbcTemplate)stockContext.getBean("jdbcTemplate");
- stockJdbcTemplate.update("delete from stock_tbl where commodity_code = 'C00321'");
- stockJdbcTemplate.update("insert into stock_tbl(commodity_code, count) values ('C00321', 100)");
- new ApplicationKeeper(stockContext).keep();
- }
-}
diff --git a/ha/src/main/resources/file.conf b/ha/src/main/resources/file.conf
deleted file mode 100644
index 02bbc5e4d..000000000
--- a/ha/src/main/resources/file.conf
+++ /dev/null
@@ -1,67 +0,0 @@
-@@ -1,66 +0,0 @@
-transport {
- # tcp udt unix-domain-socket
- type = "TCP"
- #NIO NATIVE
- server = "NIO"
- #enable heartbeat
- heartbeat = true
- # the client batch send request enable
- enableClientBatchSendRequest = true
- #thread factory for netty
- threadFactory {
- bossThreadPrefix = "NettyBoss"
- workerThreadPrefix = "NettyServerNIOWorker"
- serverExecutorThread-prefix = "NettyServerBizHandler"
- shareBossWorker = false
- clientSelectorThreadPrefix = "NettyClientSelector"
- clientSelectorThreadSize = 1
- clientWorkerThreadPrefix = "NettyClientWorkerThread"
- # netty boss thread size,will not be used for UDT
- bossThreadSize = 1
- #auto default pin or 8
- workerThreadSize = "default"
- }
- shutdown {
- # when destroy server, wait seconds
- wait = 3
- }
- serialization = "seata"
- compressor = "none"
-}
-service {
- #transaction service group mapping
- vgroupMapping.my_test_tx_group = "default"
- #only support when registry.type=file, please don't set multiple addresses
- default.grouplist = "127.0.0.1:8091"
- #degrade, current not support
- enableDegrade = false
- #disable seata
- disableGlobalTransaction = false
-}
-
-client {
- rm {
- asyncCommitBufferLimit = 10000
- lock {
- retryInterval = 10
- retryTimes = 30
- retryPolicyBranchRollbackOnConflict = true
- }
- reportRetryCount = 5
- tableMetaCheckEnable = false
- reportSuccessEnable = false
- }
- tm {
- commitRetryCount = 5
- rollbackRetryCount = 5
- }
- undo {
- dataValidation = true
- logSerialization = "jackson"
- logTable = "undo_log"
- }
- log {
- exceptionRate = 100
- }
-}
\ No newline at end of file
diff --git a/ha/src/main/resources/jdbc.properties b/ha/src/main/resources/jdbc.properties
deleted file mode 100644
index c18554dfa..000000000
--- a/ha/src/main/resources/jdbc.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 1999-2018 Alibaba Group Holding Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# account db config
-jdbc.account.url=jdbc:mysql://127.0.0.1:3306/seata
-jdbc.account.username=root
-jdbc.account.password=123456
-jdbc.account.driver=com.mysql.cj.jdbc.Driver
-# stock db config
-jdbc.stock.url=jdbc:mysql://127.0.0.1:3306/seata
-jdbc.stock.username=root
-jdbc.stock.password=123456
-jdbc.stock.driver=com.mysql.cj.jdbc.Driver
-# order db config
-jdbc.order.url=jdbc:mysql://127.0.0.1:3306/seata
-jdbc.order.username=root
-jdbc.order.password=123456
-jdbc.order.driver=com.mysql.cj.jdbc.Driver
\ No newline at end of file
diff --git a/ha/src/main/resources/logback.xml b/ha/src/main/resources/logback.xml
deleted file mode 100644
index baf4f9702..000000000
--- a/ha/src/main/resources/logback.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
- %-4relative [%thread] %-5level %logger{35} - %msg %n
-
-
-
-
-
-
-
diff --git a/ha/src/main/resources/registry.conf b/ha/src/main/resources/registry.conf
deleted file mode 100644
index ad2c5f26f..000000000
--- a/ha/src/main/resources/registry.conf
+++ /dev/null
@@ -1,96 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- application = "seata-server"
- serverAddr = "127.0.0.1:8848"
- group = "SEATA_GROUP"
- namespace = ""
- cluster = "default"
- username = "nacos"
- password = "nacos"
- }
- eureka {
- serviceUrl = "http://localhost:8761/eureka"
- application = "default"
- weight = "1"
- }
- redis {
- serverAddr = "localhost:6379"
- db = 0
- password = ""
- cluster = "default"
- timeout = 0
- }
- zk {
- cluster = "default"
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- }
- consul {
- cluster = "default"
- serverAddr = "127.0.0.1:8500"
- aclToken = ""
- }
- etcd3 {
- cluster = "default"
- serverAddr = "http://localhost:2379"
- }
- sofa {
- serverAddr = "127.0.0.1:9603"
- application = "default"
- region = "DEFAULT_ZONE"
- datacenter = "DefaultDataCenter"
- cluster = "default"
- group = "SEATA_GROUP"
- addressWaitTime = "3000"
- }
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
-
- nacos {
- serverAddr = "127.0.0.1:8848"
- namespace = ""
- group = "SEATA_GROUP"
- username = "nacos"
- password = "nacos"
- dataId = "nacos-server.properties"
- }
- consul {
- serverAddr = "127.0.0.1:8500"
- aclToken = ""
- }
- apollo {
- appId = "seata-server"
- ## apolloConfigService will cover apolloMeta
- apolloMeta = "http://192.168.1.204:8801"
- apolloConfigService = "http://192.168.1.204:8080"
- namespace = "application"
- apolloAccesskeySecret = ""
- cluster = "seata"
- }
- zk {
- serverAddr = "127.0.0.1:2181"
- sessionTimeout = 6000
- connectTimeout = 2000
- username = ""
- password = ""
- nodePath = "/seata/seata.properties"
- }
- etcd3 {
- serverAddr = "http://localhost:2379"
- }
- file {
- name = "file.conf"
- }
-}
diff --git a/ha/src/main/resources/spring/dubbo-account-service.xml b/ha/src/main/resources/spring/dubbo-account-service.xml
deleted file mode 100644
index d34df92ad..000000000
--- a/ha/src/main/resources/spring/dubbo-account-service.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ha/src/main/resources/spring/dubbo-business.xml b/ha/src/main/resources/spring/dubbo-business.xml
deleted file mode 100644
index e5e8a4883..000000000
--- a/ha/src/main/resources/spring/dubbo-business.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ha/src/main/resources/spring/dubbo-order-service.xml b/ha/src/main/resources/spring/dubbo-order-service.xml
deleted file mode 100644
index 1b27cbccf..000000000
--- a/ha/src/main/resources/spring/dubbo-order-service.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ha/src/main/resources/spring/dubbo-stock-service.xml b/ha/src/main/resources/spring/dubbo-stock-service.xml
deleted file mode 100644
index d8cebaa07..000000000
--- a/ha/src/main/resources/spring/dubbo-stock-service.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ha/src/main/resources/sql/dubbo_biz.sql b/ha/src/main/resources/sql/dubbo_biz.sql
deleted file mode 100644
index 3a97410c2..000000000
--- a/ha/src/main/resources/sql/dubbo_biz.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-DROP TABLE IF EXISTS `stock_tbl`;
-CREATE TABLE `stock_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- PRIMARY KEY (`id`),
- UNIQUE KEY (`commodity_code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `order_tbl`;
-CREATE TABLE `order_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `commodity_code` varchar(255) DEFAULT NULL,
- `count` int(11) DEFAULT 0,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-DROP TABLE IF EXISTS `account_tbl`;
-CREATE TABLE `account_tbl`
-(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `user_id` varchar(255) DEFAULT NULL,
- `money` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/ha/src/main/resources/sql/undo_log.sql b/ha/src/main/resources/sql/undo_log.sql
deleted file mode 100644
index 8ee88ab1e..000000000
--- a/ha/src/main/resources/sql/undo_log.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
-CREATE TABLE `undo_log`
-(
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `branch_id` bigint(20) NOT NULL,
- `xid` varchar(100) NOT NULL,
- `context` varchar(128) NOT NULL,
- `rollback_info` longblob NOT NULL,
- `log_status` int(11) NOT NULL,
- `log_created` datetime NOT NULL,
- `log_modified` datetime NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/mp-shadingsphere-druid-seata-tcc/.gitignore b/mp-shadingsphere-druid-seata-tcc/.gitignore
deleted file mode 100644
index 6b534701d..000000000
--- a/mp-shadingsphere-druid-seata-tcc/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.idea
-*.iml
-/target
\ No newline at end of file
diff --git a/mp-shadingsphere-druid-seata-tcc/README.md b/mp-shadingsphere-druid-seata-tcc/README.md
deleted file mode 100644
index 5b8dbf3c7..000000000
--- a/mp-shadingsphere-druid-seata-tcc/README.md
+++ /dev/null
@@ -1,139 +0,0 @@
-# mp-shadingsphere-druid-seata-tcc
-
-## 准备环境
-
-1. 创建mysql 数据库,导入脚本
-
-2. 启动 Nacos server
- [Nacos Server 下载地址](https://github.com/alibaba/nacos/releases)
-
-> 下载最新版本Nacos Server, 本地启动Nacos
-
-注: 分别导入 doc service-A-dev.yml,service-B-dev.yml 配置文件到nacos
-
-3. 启动Seata Server
- [Seata Server 下载地址](https://github.com/seata/seata/releases)
-
-> 下载最新版本Seata Server, 本地启动Seata
-
-4. 启动A 启动B
-
-5. 访问API
-
- localhost:8070/geneOrder
-
-6. 观察事务回滚效果
-
-> 注释 UserOrderServiceImpl 的代码 int a = 1 / 0; 可以观察事务回滚情况
-
-## 使用组件介绍
-
-* Nacos 注册中心
-* Nacos 配置中心
-* Open Feign REST 服务调用
-* Sentinel 限流熔断
-* Seata 分布式事务解决方案
-
-## 项目目录介绍
-
-- mp-shadingsphere-druid-seata-tcc
- - base-common
- `通用常量 vo`
- - base-starter
- `通用star组件`
- - base-core-starter
- `核心依赖,集成了nacos注册配置中心,openfeign,sentinel,validator`
- - base-jdbc-starter
- `持久化依赖,集成了mybatis-plus+druid+shardingsphere(分库分表+读写分离)`
- - base-transaction-starter
- `分布式事务依赖,集成了seata分布式事务(主要使用tcc模式)`
- - demo-service-A
- `订单服务`
- - demo-service-B
- `产品库存服务`
- - doc `sql数据库和yaml配置`
-
-> 注意: 使用seata tcc模式的时候请关闭 enable-auto-data-source-proxy: false 自动代码,否则tcc模式执行后会执行at模式
-
-- 版本
-
-```xml
-3.4.1
-1.1.22
-8.0.21
-4.0.0-RC2
-```
-
-## demo
-
-场景:
-当创建订单的时候库存-1
-此时两个服务为分布式事务操作
-> 当两个服务调用完毕的时候1/0,发生异常,两个数据回滚
-
-## 关键代码
-
-```java
-@Override
-@GlobalTransactional
-@Transactional
-public void geneOrder(UserOrder userOrder) {
- // 扣减库存
- ResponseEntity forEntity = restTemplate.getForEntity("http://localhost:8071/deduct?id=1", Result.class);
- if(forEntity.getStatusCode() != HttpStatus.OK ||
- Optional.ofNullable(forEntity.getBody()).orElse(new Result()).getCode() != 200) {
- throw new RuntimeException("扣减库存失败!");
- }
- // 生成订单
- long id = IdWorker.getId();
- userOrder.setId(id);
- userOrderTccAction.geneOrder(userOrder,id);
-
- int a = 1/0;
-}
-```
-
-## 运行结果
-
-- 订单服务
-
-```
-2021-04-29 15:57:35.909 INFO 9104 --- [nio-8070-exec-1] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [127.0.0.1:8091:27149561796388640]
-2021-04-29 15:57:39.033 INFO 9104 --- [nio-8070-exec-1] ShardingSphere-SQL : Rule Type: master-slave
-2021-04-29 15:57:39.033 INFO 9104 --- [nio-8070-exec-1] ShardingSphere-SQL : SQL: INSERT INTO user_order ( id,
-order_id,
-p_id ) VALUES ( ?,
-?,
-? ) ::: DataSources: master
-2021-04-29 15:57:39.063 INFO 9104 --- [nio-8070-exec-1] c.d.m.o.a.impl.UserOrderTccActionImpl : geneOrder---------------------1387677438737305602
-2021-04-29 15:57:39.149 INFO 9104 --- [h_RMROLE_1_1_12] i.s.c.r.p.c.RmBranchRollbackProcessor : rm handle branch rollback process:xid=127.0.0.1:8091:27149561796388640,branchId=27149561796388658,branchType=TCC,resourceId=gene-order,applicationData={"actionContext":{"action-start-time":1619683057855,"sys::prepare":"geneOrder","sys::rollback":"cancel","sys::commit":"commit","id":1387677438737305602,"host-name":"169.254.174.68","actionName":"gene-order"}}
-2021-04-29 15:57:39.157 INFO 9104 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 127.0.0.1:8091:27149561796388640 27149561796388658 gene-order
-2021-04-29 15:57:39.174 INFO 9104 --- [h_RMROLE_1_1_12] c.d.m.o.a.impl.UserOrderTccActionImpl : cancel---------------------1387677438737305602
-2021-04-29 15:57:39.191 INFO 9104 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : Rule Type: master-slave
-2021-04-29 15:57:39.191 INFO 9104 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : SQL: DELETE FROM user_order WHERE id=? ::: DataSources: master
-2021-04-29 15:57:39.197 INFO 9104 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractResourceManager : TCC resource rollback result : true, xid: 127.0.0.1:8091:27149561796388640, branchId: 27149561796388658, resourceId: gene-order
-2021-04-29 15:57:39.199 INFO 9104 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
-2021-04-29 15:57:39.314 INFO 9104 --- [nio-8070-exec-1] i.seata.tm.api.DefaultGlobalTransaction : [127.0.0.1:8091:27149561796388640] rollback status: Rollbacked
-2021-04-29 15:57:39.338 ERROR 9104 --- [nio-8070-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ArithmeticException: / by zero] with root cause
-
-java.lang.ArithmeticException: / by zero
-```
-
-- 库存服务
-
-```
-2021-04-29 15:57:39.221 INFO 4656 --- [h_RMROLE_1_1_12] i.s.c.r.p.c.RmBranchRollbackProcessor : rm handle branch rollback process:xid=127.0.0.1:8091:27149561796388640,branchId=27149561796388642,branchType=TCC,resourceId=order-decuct,applicationData={"actionContext":{"action-start-time":1619683056387,"sys::prepare":"deduct","sys::rollback":"cancel","sys::commit":"commit","id":1,"host-name":"169.254.174.68","actionName":"order-decuct"}}
-2021-04-29 15:57:39.229 INFO 4656 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 127.0.0.1:8091:27149561796388640 27149561796388642 order-decuct
-2021-04-29 15:57:39.251 INFO 4656 --- [h_RMROLE_1_1_12] c.d.m.p.a.impl.CompanyProductActionImpl : cancel---------------------1
-2021-04-29 15:57:39.252 INFO 4656 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : Rule Type: master-slave
-2021-04-29 15:57:39.252 INFO 4656 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : SQL: SELECT id,product_name,account FROM company_product
-
- WHERE (id = ?) ::: DataSources: slave02
-2021-04-29 15:57:39.257 INFO 4656 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : Rule Type: master-slave
-2021-04-29 15:57:39.257 INFO 4656 --- [h_RMROLE_1_1_12] ShardingSphere-SQL : SQL: UPDATE company_product SET product_name=?,
-account=? WHERE id=? ::: DataSources: master
-2021-04-29 15:57:39.264 INFO 4656 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractResourceManager : TCC resource rollback result : true, xid: 127.0.0.1:8091:27149561796388640, branchId: 27149561796388642, resourceId: order-decuct
-2021-04-29 15:57:39.266 INFO 4656 --- [h_RMROLE_1_1_12] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked
-```
-
-感谢seata团队的帮助。
\ No newline at end of file
diff --git a/mp-shadingsphere-druid-seata-tcc/base-common/pom.xml b/mp-shadingsphere-druid-seata-tcc/base-common/pom.xml
deleted file mode 100644
index 9e1a9f519..000000000
--- a/mp-shadingsphere-druid-seata-tcc/base-common/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
- mp-shadingsphere-druid-seata-tcc
- com.seata
- 1.0.0-SNAPSHOT
-
- 4.0.0
-
- base-common
- 1.0.0-SNAPSHOT
-
-
-
- cn.hutool
- hutool-all
- ${hutool-all.version}
-
-
-
- commons-beanutils
- commons-beanutils
- ${commons-beanutils.version}
-
-
- org.apache.commons
- commons-pool2
-
-
- com.auth0
- java-jwt
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
-
-
\ No newline at end of file
diff --git a/mp-shadingsphere-druid-seata-tcc/base-common/src/main/java/com/seata/common/api/vo/Result.java b/mp-shadingsphere-druid-seata-tcc/base-common/src/main/java/com/seata/common/api/vo/Result.java
deleted file mode 100644
index ec917cacf..000000000
--- a/mp-shadingsphere-druid-seata-tcc/base-common/src/main/java/com/seata/common/api/vo/Result.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 1999-2021 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.seata.common.api.vo;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.seata.common.constant.CommonConstant;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * 接口返回数据格式
- */
-@Data
-@ApiModel(value = "接口返回对象", description = "接口返回对象")
-public class Result implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 成功标志
- */
- @ApiModelProperty(value = "成功标志")
- private boolean success = true;
-
- /**
- * 返回处理消息
- */
- @ApiModelProperty(value = "返回处理消息")
- private String message = "操作成功!";
-
- /**
- * 返回代码
- */
- @ApiModelProperty(value = "返回代码")
- private Integer code = 0;
-
- /**
- * 返回数据对象 data
- */
- @ApiModelProperty(value = "返回数据对象")
- private T result;
-
- /**
- * 时间戳
- */
- @ApiModelProperty(value = "时间戳")
- private long timestamp = System.currentTimeMillis();
-
- public Result() {
-
- }
-
- public Result success(String message) {
- this.message = message;
- this.code = CommonConstant.SC_OK_200;
- this.success = true;
- return this;
- }
-
- @Deprecated
- public static Result