You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by ji...@apache.org on 2024/03/16 13:18:57 UTC
(incubator-seata-samples) branch master updated: feature: upgrade samples seata dependency to 2.0 (#646) (#647)
This is an automated email from the ASF dual-hosted git repository.
jimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-seata-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 229a6187 feature: upgrade samples seata dependency to 2.0 (#646) (#647)
229a6187 is described below
commit 229a618720620e0bbf070f0737f0263ae9b4accc
Author: wt_better <m1...@163.com>
AuthorDate: Sat Mar 16 21:18:53 2024 +0800
feature: upgrade samples seata dependency to 2.0 (#646) (#647)
---
.gitignore | 1 +
README.md | 91 +-
api/pom.xml | 35 -
.../main/java/io/seata/samples/api/Bussiness.java | 101 -
.../samples/api/service/AbstractDataCheck.java | 48 -
.../seata/samples/api/service/AccountService.java | 35 -
.../samples/api/service/DataResetService.java | 35 -
.../io/seata/samples/api/service/OrderService.java | 43 -
.../io/seata/samples/api/service/StockService.java | 35 -
.../api/service/impl/AccountServiceImpl.java | 57 -
.../samples/api/service/impl/OrderServiceImpl.java | 58 -
.../samples/api/service/impl/StockServiceImpl.java | 57 -
.../io/seata/samples/api/utils/DataSourceUtil.java | 146 -
.../io/seata/samples/api/utils/PropertiesUtil.java | 61 -
api/src/main/resources/all.sql | 41 -
api/src/main/resources/file.conf | 10 -
api/src/main/resources/jdbc.properties | 14 -
api/src/main/resources/registry.conf | 82 -
at-sample/at-api/pom.xml | 79 +
.../java/org/apache/seata/api/BusinessService.java | 121 +
.../seata/api/service/AbstractDataCheck.java | 49 +
.../apache/seata/api/service/AccountService.java | 36 +
.../apache/seata/api/service/DataResetService.java | 36 +
.../org/apache/seata/api/service/OrderService.java | 44 +
.../apache/seata/api/service/StorageService.java | 36 +
.../seata/api/service/impl/AccountServiceImpl.java | 59 +
.../seata/api/service/impl/OrderServiceImpl.java | 60 +
.../seata/api/service/impl/StorageServiceImpl.java | 60 +
.../org/apache/seata/api/utils/DataSourceUtil.java | 139 +
.../org/apache/seata/api/utils/PropertiesUtil.java | 61 +
at-sample/at-api/src/main/resources/all.sql | 56 +
at-sample/at-api/src/main/resources/file.conf | 126 +
.../at-api/src/main/resources/jdbc.properties | 14 +
at-sample/at-api/src/main/resources/registry.conf | 124 +
at-sample/spring-dubbo-seata/pom.xml | 104 +
.../seata/account/DubboAccountServiceStarter.java | 47 +
.../account/config/DataSourceConfiguration.java | 60 +
.../seata/account/config/DubboConfiguration.java | 59 +
.../seata/account/config/SeataConfiguration.java | 45 +
.../seata/account/service/AccountService.java | 28 +
.../account/service/impl/AccountServiceImpl.java | 46 +
.../seata/business/DubboBusinessServiceTester.java | 51 +
.../seata/business/config/DubboConfiguration.java | 51 +
.../seata/business/config/SeataConfiguration.java | 45 +
.../seata/business/service/BusinessService.java | 29 +
.../business/service/impl/BusinessServiceImpl.java | 54 +
.../seata/order/DubboOrderServiceStarter.java | 47 +
.../order/config/DataSourceConfiguration.java | 60 +
.../seata/order/config/DubboConfiguration.java | 59 +
.../seata/order/config/SeataConfiguration.java | 45 +
.../apache/seata/order/service/OrderService.java | 29 +
.../seata/order/service/impl/OrderServiceImpl.java | 79 +
.../seata/storage/DubboStorageServiceStarter.java | 47 +
.../storage/config/DataSourceConfiguration.java | 60 +
.../seata/storage/config/DubboConfiguration.java | 59 +
.../seata/storage/config/SeataConfiguration.java | 45 +
.../seata/storage/service/StorageService.java | 36 +
.../storage/service/impl/StorageServiceImpl.java | 61 +
.../spring-dubbo-seata/src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 18 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
at-sample/spring-seata/pom.xml | 86 +
.../org/apache/seata/BusinessServiceTester.java | 57 +
.../seata/config/DataSourceConfiguration.java | 58 +
.../apache/seata/config/SeataConfiguration.java | 45 +
.../org/apache/seata/service/AccountService.java | 31 +
.../org/apache/seata/service/BusinessService.java | 32 +
.../org/apache/seata/service/OrderService.java | 33 +
.../org/apache/seata/service/StorageService.java | 31 +
.../seata/service/impl/AccountServiceImpl.java | 50 +
.../seata/service/impl/BusinessServiceImpl.java | 60 +
.../seata/service/impl/OrderServiceImpl.java | 84 +
.../seata/service/impl/StorageServiceImpl.java | 52 +
at-sample/spring-seata/src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 5 +
.../spring-seata/src/main/resources/file.conf | 126 +
.../spring-seata/src/main/resources/registry.conf | 124 +
at-sample/springboot-dubbo-seata/pom.xml | 47 +
.../springboot-dubbo-seata-account/pom.xml | 123 +
.../SpringbootDubboSeataAccountApplication.java | 29 +
.../seata/service/impl/AccountServiceImpl.java | 46 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 12 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-dubbo-seata-business/pom.xml | 111 +
.../SpringbootDubboSeataBusinessApplication.java | 43 +
.../org/apache/seata/service/BusinessService.java | 32 +
.../seata/service/impl/BusinessServiceImpl.java | 54 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 8 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-dubbo-seata-common/pom.xml | 33 +
.../org/apache/seata/service/AccountService.java | 28 +
.../org/apache/seata/service/OrderService.java | 29 +
.../org/apache/seata/service/StorageService.java | 36 +
.../springboot-dubbo-seata-order/pom.xml | 123 +
.../SpringbootDubboSeataOrderApplication.java | 29 +
.../seata/service/impl/OrderServiceImpl.java | 79 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 12 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-dubbo-seata-storage/pom.xml | 105 +
.../SpringbootDubboSeataStorageApplication.java | 29 +
.../seata/service/impl/StorageServiceImpl.java | 61 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 12 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
at-sample/springboot-mybatis-seata/pom.xml | 88 +
.../apache/seata/SpringbootSeataApplication.java | 47 +
.../src/main/java/org/apache/seata/TestData.java | 23 +
.../java/org/apache/seata/dao/AccountMapper.java | 32 +
.../java/org/apache/seata/dao/OrderMapper.java | 29 +
.../java/org/apache/seata/dao/StorageMapper.java | 41 +
.../main/java/org/apache/seata/model/Account.java | 49 +
.../main/java/org/apache/seata/model/Order.java | 71 +
.../main/java/org/apache/seata/model/Storage.java | 50 +
.../org/apache/seata/service/AccountService.java | 31 +
.../org/apache/seata/service/BusinessService.java | 32 +
.../org/apache/seata/service/OrderService.java | 33 +
.../org/apache/seata/service/StorageService.java | 31 +
.../seata/service/impl/AccountServiceImpl.java | 53 +
.../seata/service/impl/BusinessServiceImpl.java | 75 +
.../seata/service/impl/OrderServiceImpl.java | 63 +
.../seata/service/impl/StorageServiceImpl.java | 54 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 10 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/mapper/AccountMapper.xml | 22 +
.../src/main/resources/mapper/OrderMapper.xml | 18 +
.../src/main/resources/mapper/StorageMapper.xml | 49 +
.../src/main/resources/registry.conf | 124 +
at-sample/springboot-seata/pom.xml | 82 +
.../apache/seata/SpringbootSeataApplication.java | 31 +
.../org/apache/seata/service/AccountService.java | 31 +
.../org/apache/seata/service/BusinessService.java | 32 +
.../org/apache/seata/service/OrderService.java | 33 +
.../org/apache/seata/service/StorageService.java | 31 +
.../seata/service/impl/AccountServiceImpl.java | 50 +
.../seata/service/impl/BusinessServiceImpl.java | 59 +
.../seata/service/impl/OrderServiceImpl.java | 84 +
.../seata/service/impl/StorageServiceImpl.java | 52 +
.../springboot-seata/src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 8 +
.../springboot-seata/src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
doc/img/fescar-1.png | Bin 101828 -> 0 bytes
doc/img/fescar-2.png | Bin 324922 -> 0 bytes
doc/img/fescar.png | Bin 20616 -> 0 bytes
doc/img/nacos-1.png | Bin 361997 -> 0 bytes
doc/img/nacos-2.png | Bin 151219 -> 0 bytes
doc/img/nacos-3.png | Bin 231469 -> 0 bytes
doc/img/seata.png | Bin 23415 -> 0 bytes
doc/quick-integration-with-spring-cloud.md | 394 -
dubbo-multiple-datasource-mybatis-plus/README.md | 21 -
.../common/pom.xml | 19 -
.../main/java/io/seata/samples/entity/Account.java | 48 -
.../main/java/io/seata/samples/entity/Orders.java | 55 -
.../main/java/io/seata/samples/entity/Product.java | 51 -
.../java/io/seata/samples/service/DemoService.java | 38 -
.../io/seata/samples/service/IAccountService.java | 32 -
.../io/seata/samples/service/IOrdersService.java | 32 -
.../io/seata/samples/service/IProductService.java | 32 -
.../consumer/pom.xml | 20 -
.../java/io/seata/samples/ClientApplication.java | 43 -
.../io/seata/samples/config/SeataAutoConfig.java | 39 -
.../seata/samples/controller/TestController.java | 82 -
.../main/java/io/seata/samples/entity/Account.java | 48 -
.../main/java/io/seata/samples/entity/Orders.java | 55 -
.../main/java/io/seata/samples/entity/Product.java | 51 -
.../java/io/seata/samples/service/DemoService.java | 39 -
.../io/seata/samples/service/DemoServiceImpl.java | 136 -
.../io/seata/samples/service/IAccountService.java | 32 -
.../io/seata/samples/service/IOrdersService.java | 32 -
.../io/seata/samples/service/IProductService.java | 32 -
.../consumer/src/main/resources/application.yml | 32 -
.../consumer/src/main/resources/registry.conf | 82 -
dubbo-multiple-datasource-mybatis-plus/pom.xml | 98 -
.../provider/pom.xml | 35 -
.../java/io/seata/samples/ProviderApplication.java | 38 -
.../io/seata/samples/config/MybatisPlusConfig.java | 47 -
.../io/seata/samples/config/SeataAutoConfig.java | 39 -
.../io/seata/samples/mapper/AccountMapper.java | 28 -
.../java/io/seata/samples/mapper/OrdersMapper.java | 28 -
.../io/seata/samples/mapper/ProductMapper.java | 28 -
.../samples/service/impl/AccountServiceImpl.java | 32 -
.../samples/service/impl/OrdersServiceImpl.java | 33 -
.../samples/service/impl/ProductServiceImpl.java | 32 -
.../provider/src/main/resources/application.yml | 51 -
.../src/main/resources/mapper/AccountMapper.xml | 5 -
.../src/main/resources/mapper/OrdersMapper.xml | 5 -
.../src/main/resources/mapper/ProductMapper.xml | 5 -
.../provider/src/main/resources/registry.conf | 96 -
.../sql/test_order.sql | 32 -
.../sql/test_pay.sql | 28 -
.../sql/test_storage.sql | 26 -
dubbo/README.md | 28 -
dubbo/pom.xml | 98 -
.../io/seata/samples/dubbo/ApplicationKeeper.java | 79 -
.../main/java/io/seata/samples/dubbo/Order.java | 50 -
.../samples/dubbo/service/AccountService.java | 30 -
.../samples/dubbo/service/BusinessService.java | 31 -
.../seata/samples/dubbo/service/OrderService.java | 33 -
.../seata/samples/dubbo/service/StockService.java | 38 -
.../dubbo/service/impl/AccountServiceImpl.java | 54 -
.../dubbo/service/impl/BusinessServiceImpl.java | 74 -
.../dubbo/service/impl/OrderServiceImpl.java | 113 -
.../dubbo/service/impl/StockServiceImpl.java | 70 -
.../dubbo/starter/DubboAccountServiceStarter.java | 41 -
.../samples/dubbo/starter/DubboBusinessTester.java | 40 -
.../dubbo/starter/DubboOrderServiceStarter.java | 39 -
.../dubbo/starter/DubboStockServiceStarter.java | 40 -
dubbo/src/main/resources/file.conf | 66 -
dubbo/src/main/resources/jdbc.properties | 29 -
dubbo/src/main/resources/log4j.properties | 6 -
dubbo/src/main/resources/registry.conf | 79 -
.../resources/spring/dubbo-account-service.xml | 78 -
dubbo/src/main/resources/spring/dubbo-business.xml | 50 -
.../main/resources/spring/dubbo-order-service.xml | 81 -
.../main/resources/spring/dubbo-stock-service.xml | 78 -
dubbo/src/main/resources/sql/dubbo_biz.sql | 31 -
dubbo/src/main/resources/sql/undo_log.sql | 14 -
etcd3/api-etcd3-samples/pom.xml | 41 -
.../java/io/seata/samples/etcd3/api/Bussiness.java | 102 -
.../etcd3/api/service/AbstractDataCheck.java | 47 -
.../samples/etcd3/api/service/AccountService.java | 34 -
.../etcd3/api/service/DataResetService.java | 34 -
.../samples/etcd3/api/service/OrderService.java | 42 -
.../samples/etcd3/api/service/StockService.java | 34 -
.../etcd3/api/service/impl/AccountServiceImpl.java | 58 -
.../etcd3/api/service/impl/OrderServiceImpl.java | 59 -
.../etcd3/api/service/impl/StockServiceImpl.java | 58 -
.../samples/etcd3/api/utils/DataSourceUtil.java | 146 -
.../samples/etcd3/api/utils/PropertiesUtil.java | 60 -
etcd3/api-etcd3-samples/src/main/resources/all.sql | 41 -
.../api-etcd3-samples/src/main/resources/file.conf | 10 -
.../src/main/resources/jdbc.properties | 14 -
.../src/main/resources/registry.conf | 82 -
etcd3/pom.xml | 31 -
ha/Readme.md | 421 -
ha/pom.xml | 126 -
.../io/seata/samples/nacos/ApplicationKeeper.java | 78 -
ha/src/main/java/io/seata/samples/nacos/Order.java | 50 -
.../samples/nacos/service/AccountService.java | 30 -
.../samples/nacos/service/BusinessService.java | 31 -
.../seata/samples/nacos/service/OrderService.java | 33 -
.../seata/samples/nacos/service/StockService.java | 30 -
.../nacos/service/impl/AccountServiceImpl.java | 53 -
.../nacos/service/impl/BusinessServiceImpl.java | 66 -
.../nacos/service/impl/OrderServiceImpl.java | 112 -
.../nacos/service/impl/StockServiceImpl.java | 56 -
.../nacos/starter/DubboAccountServiceStarter.java | 41 -
.../samples/nacos/starter/DubboBusinessTester.java | 42 -
.../nacos/starter/DubboOrderServiceStarter.java | 39 -
.../nacos/starter/DubboStockServiceStarter.java | 40 -
ha/src/main/resources/file.conf | 67 -
ha/src/main/resources/jdbc.properties | 30 -
ha/src/main/resources/logback.xml | 29 -
ha/src/main/resources/registry.conf | 96 -
.../resources/spring/dubbo-account-service.xml | 74 -
ha/src/main/resources/spring/dubbo-business.xml | 48 -
.../main/resources/spring/dubbo-order-service.xml | 78 -
.../main/resources/spring/dubbo-stock-service.xml | 74 -
ha/src/main/resources/sql/dubbo_biz.sql | 31 -
ha/src/main/resources/sql/undo_log.sql | 14 -
mp-shadingsphere-druid-seata-tcc/.gitignore | 3 -
mp-shadingsphere-druid-seata-tcc/README.md | 139 -
.../base-common/pom.xml | 44 -
.../main/java/com/seata/common/api/vo/Result.java | 167 -
.../com/seata/common/constant/CommonConstant.java | 147 -
.../base-starter/base-core-starter/pom.xml | 53 -
.../starter/core/config/FeignClientConfig.java | 105 -
.../core/config/JacksonAutoConfiguration.java | 183 -
.../starter/core/config/Knife4jConfiguration.java | 57 -
.../core/config/PersonBeanConfiguration.java | 37 -
.../seata/starter/core/feign/IFeignService.java | 21 -
.../starter/core/feign/impl/IFeignServiceImpl.java | 70 -
.../core/handler/GlobalExceptionHandler.java | 56 -
.../src/main/resources/META-INF/spring.factories | 2 -
.../src/main/resources/bootstrap.yml | 43 -
.../base-starter/base-jdbc-starter/pom.xml | 92 -
.../starter/jdbc/config/MybatisPlusConfig.java | 40 -
.../src/main/resources/META-INF/spring.factories | 2 -
.../base-starter/base-transaction-starter/pom.xml | 67 -
.../transaction/config/MybatisPlusAutoConfig.java | 290 -
.../starter/transaction/config/SeataConfig.java | 43 -
.../src/main/resources/META-INF/spring.factories | 3 -
.../base-starter/pom.xml | 34 -
.../demo-service-A/pom.xml | 32 -
.../src/main/java/com/demo/ServiceAApp.java | 39 -
.../modules/order/action/UserOrderTccAction.java | 32 -
.../order/action/impl/UserOrderTccActionImpl.java | 63 -
.../order/controller/UserOrderController.java | 44 -
.../com/demo/modules/order/entity/UserOrder.java | 30 -
.../demo/modules/order/mapper/UserOrderMapper.java | 21 -
.../modules/order/mapper/xml/UserOrderMapper.xml | 22 -
.../modules/order/service/UserOderService.java | 23 -
.../order/service/impl/UserOderServiceImpl.java | 60 -
.../src/main/resources/application.yml | 3 -
.../src/main/resources/bootstrap.properties | 4 -
.../src/main/resources/config.properties | 0
.../demo-service-A/src/main/resources/file.conf | 118 -
.../src/main/resources/registry.conf | 89 -
.../demo-service-A/src/main/resources/seata.conf | 4 -
.../demo-service-B/pom.xml | 32 -
.../src/main/java/com/demo/ServiceBApp.java | 32 -
.../product/action/CompanyProductAction.java | 31 -
.../action/impl/CompanyProductActionImpl.java | 57 -
.../controller/CompanyProductController.java | 39 -
.../modules/product/entity/CompanyProduct.java | 33 -
.../product/mapper/CompanyProductMapper.java | 21 -
.../product/mapper/xml/CompanyProductMapper.xml | 22 -
.../product/service/ICompanyProductService.java | 21 -
.../product/service/impl/CompanyProductImpl.java | 26 -
.../src/main/resources/application.yml | 3 -
.../src/main/resources/bootstrap.properties | 4 -
.../src/main/resources/config.properties | 0
.../demo-service-B/src/main/resources/file.conf | 118 -
.../src/main/resources/registry.conf | 89 -
.../demo-service-B/src/main/resources/seata.conf | 4 -
.../doc/seata-test-service-a.sql | 35 -
.../doc/seata-test-service-b.sql | 40 -
.../doc/service-A-dev.yml | 126 -
.../doc/service-B-dev.yml | 126 -
mp-shadingsphere-druid-seata-tcc/pom.xml | 308 -
multiple-datasource-mybatis-plus/README.md | 79 -
multiple-datasource-mybatis-plus/data.sql | 106 -
multiple-datasource-mybatis-plus/pom.xml | 95 -
.../MultipleDatasourceMyBatisPlusApplication.java | 18 -
.../mybatisplus/common/OperationResponse.java | 24 -
.../mutiple/mybatisplus/common/order/Order.java | 31 -
.../mybatisplus/common/order/OrderStatus.java | 21 -
.../common/order/PlaceOrderRequestVO.java | 23 -
.../mutiple/mybatisplus/common/pay/Account.java | 20 -
.../common/pay/ReduceBalanceRequestVO.java | 22 -
.../mutiple/mybatisplus/common/stock/Product.java | 22 -
.../common/stock/ReduceStockRequestVO.java | 22 -
.../mutiple/mybatisplus/config/DataSourceKey.java | 23 -
.../mybatisplus/config/DataSourceProxyConfig.java | 85 -
.../config/DynamicDataSourceContextHolder.java | 30 -
.../config/DynamicRoutingDataSource.java | 17 -
.../mybatisplus/controller/OrderController.java | 31 -
.../mutiple/mybatisplus/dao/AccountDao.java | 13 -
.../samples/mutiple/mybatisplus/dao/OrderDao.java | 13 -
.../mutiple/mybatisplus/dao/ProductDao.java | 13 -
.../mutiple/mybatisplus/service/OrderService.java | 18 -
.../mutiple/mybatisplus/service/PayService.java | 15 -
.../mutiple/mybatisplus/service/StockService.java | 16 -
.../mybatisplus/service/impl/OrderServiceImpl.java | 67 -
.../mybatisplus/service/impl/PayServiceImpl.java | 67 -
.../mybatisplus/service/impl/StockServiceImpl.java | 64 -
.../src/main/resources/application.properties | 20 -
.../src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
...tipleDatasourceMyBatisPlusApplicationTests.java | 16 -
multiple-datasource/README.md | 79 -
multiple-datasource/data.sql | 106 -
multiple-datasource/pom.xml | 95 -
.../datasource/MultipleDatasourceApplication.java | 16 -
.../datasource/common/OperationResponse.java | 24 -
.../mutiple/datasource/common/order/Order.java | 26 -
.../datasource/common/order/OrderStatus.java | 21 -
.../common/order/PlaceOrderRequestVO.java | 23 -
.../common/pay/ReduceBalanceRequestVO.java | 22 -
.../common/stock/ReduceStockRequestVO.java | 22 -
.../mutiple/datasource/config/DataSourceKey.java | 23 -
.../datasource/config/DataSourceProxyConfig.java | 86 -
.../config/DynamicDataSourceContextHolder.java | 30 -
.../config/DynamicRoutingDataSource.java | 17 -
.../datasource/controller/OrderController.java | 31 -
.../samples/mutiple/datasource/dao/AccountDao.java | 31 -
.../samples/mutiple/datasource/dao/OrderDao.java | 39 -
.../samples/mutiple/datasource/dao/ProductDao.java | 32 -
.../mutiple/datasource/service/OrderService.java | 18 -
.../mutiple/datasource/service/PayService.java | 15 -
.../mutiple/datasource/service/StockService.java | 16 -
.../datasource/service/impl/OrderServiceImpl.java | 68 -
.../datasource/service/impl/PayServiceImpl.java | 57 -
.../datasource/service/impl/StockServiceImpl.java | 58 -
.../src/main/resources/application.properties | 19 -
multiple-datasource/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
.../MultipleDatasourceApplicationTests.java | 16 -
nacos/Readme.md | 380 -
nacos/pom.xml | 118 -
.../io/seata/samples/nacos/ApplicationKeeper.java | 78 -
.../main/java/io/seata/samples/nacos/Order.java | 50 -
.../samples/nacos/service/AccountService.java | 30 -
.../samples/nacos/service/BusinessService.java | 31 -
.../seata/samples/nacos/service/OrderService.java | 33 -
.../seata/samples/nacos/service/StockService.java | 30 -
.../nacos/service/impl/AccountServiceImpl.java | 53 -
.../nacos/service/impl/BusinessServiceImpl.java | 65 -
.../nacos/service/impl/OrderServiceImpl.java | 112 -
.../nacos/service/impl/StockServiceImpl.java | 56 -
.../nacos/starter/DubboAccountServiceStarter.java | 41 -
.../samples/nacos/starter/DubboBusinessTester.java | 40 -
.../nacos/starter/DubboOrderServiceStarter.java | 39 -
.../nacos/starter/DubboStockServiceStarter.java | 40 -
nacos/src/main/resources/file.conf | 66 -
nacos/src/main/resources/jdbc.properties | 30 -
nacos/src/main/resources/logback.xml | 30 -
nacos/src/main/resources/registry.conf | 89 -
.../resources/spring/dubbo-account-service.xml | 76 -
nacos/src/main/resources/spring/dubbo-business.xml | 47 -
.../main/resources/spring/dubbo-order-service.xml | 80 -
.../resources/spring/dubbo-storage-service.xml | 76 -
nacos/src/main/resources/sql/dubbo_biz.sql | 31 -
nacos/src/main/resources/sql/undo_log.sql | 14 -
.../nutzboot-dubbo-fescar-account/.gitignore | 1 -
.../nutzboot-dubbo-fescar-account/pom.xml | 17 -
.../rpc/DemoFescarAccountServiceLauncher.java | 30 -
.../dubbo/rpc/service/impl/AccountServiceImpl.java | 33 -
.../src/main/resources/application.properties | 11 -
.../src/main/resources/log4j.properties | 5 -
.../nutzboot-dubbo-fescar-common/.gitignore | 1 -
.../nutzboot-dubbo-fescar-common/bin/pom.xml | 23 -
.../nutzboot-dubbo-fescar-common/pom.xml | 12 -
.../src/main/java/io/nutz/demo/bean/Account.java | 46 -
.../src/main/java/io/nutz/demo/bean/Order.java | 63 -
.../src/main/java/io/nutz/demo/bean/Stock.java | 41 -
.../demo/dubbo/rpc/service/AccountService.java | 9 -
.../demo/dubbo/rpc/service/BusinessService.java | 6 -
.../nutz/demo/dubbo/rpc/service/OrderService.java | 11 -
.../nutz/demo/dubbo/rpc/service/StockService.java | 9 -
.../nutzboot-dubbo-fescar-order/.gitignore | 1 -
.../nutzboot-dubbo-fescar-order/pom.xml | 17 -
.../dubbo/rpc/DemoFescarOrderServiceLauncher.java | 23 -
.../dubbo/rpc/service/impl/OrderServiceImpl.java | 43 -
.../src/main/resources/application.properties | 11 -
.../src/main/resources/log4j.properties | 5 -
.../nutzboot-dubbo-fescar-stock/.gitignore | 1 -
.../nutzboot-dubbo-fescar-stock/pom.xml | 17 -
.../dubbo/rpc/DemoFescarStockServiceLauncher.java | 30 -
.../dubbo/rpc/service/impl/StockServiceImpl.java | 42 -
.../src/main/resources/application.properties | 11 -
.../src/main/resources/log4j.properties | 5 -
.../nutzboot-dubbo-fescar-web/.gitignore | 1 -
.../nutzboot-dubbo-fescar-web/pom.xml | 27 -
.../nutz/demo/dubbo/rpc/DemoFescarWebLauncher.java | 65 -
.../rpc/service/impl/BusinessServiceImpl.java | 44 -
.../src/main/resources/application.properties | 12 -
.../src/main/resources/log4j.properties | 5 -
.../src/main/resources/static/index.html | 64 -
.../src/main/resources/static/jquery-3.3.1.min.js | 2 -
.../src/main/resources/static/vue.js | 12249 -------------------
nutzboot-dubbo-fescar/pom.xml | 167 -
pom.xml | 394 +-
saga-sample/spring-dubbo-seata-saga/pom.xml | 119 +
.../seata/consumer/SagaTransactionStarter.java | 138 +
.../consumer/config/DataSourceConfiguration.java | 50 +
.../config/DubboConsumerConfiguration.java | 65 +
.../seata/consumer/config/SagaConfiguration.java | 48 +
.../seata/provider/DubboProviderStarter.java | 62 +
.../seata/provider/action/BalanceAction.java | 46 +
.../seata/provider/action/InventoryAction.java | 38 +
.../provider/action/impl/BalanceActionImpl.java | 58 +
.../provider/action/impl/InventoryActionImpl.java | 43 +
.../config/DubboProviderConfiguration.java | 55 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../src/main/resources/sql/h2_init.sql | 74 +
.../statelang/reduce_inventory_and_balance.json | 0
saga-sample/spring-seata-saga/pom.xml | 87 +
.../org/apache/seata/SagaTransactionStarter.java | 132 +
.../org/apache/seata/action/BalanceAction.java | 46 +
.../org/apache/seata/action/InventoryAction.java | 38 +
.../seata/action/impl/BalanceActionImpl.java | 56 +
.../seata/action/impl/InventoryActionImpl.java | 41 +
.../spring-seata-saga/src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../src/main/resources/spring/seata-saga.xml | 68 +
.../src/main/resources/sql/h2_init.sql | 74 +
.../statelang/reduce_inventory_and_balance.json | 0
saga/README.MD | 8 -
saga/dubbo-saga-sample/README.MD | 54 -
saga/dubbo-saga-sample/pom.xml | 104 -
.../io/seata/samples/saga/ApplicationKeeper.java | 78 -
.../seata/samples/saga/action/BalanceAction.java | 45 -
.../seata/samples/saga/action/InventoryAction.java | 37 -
.../saga/action/impl/BalanceActionImpl.java | 55 -
.../saga/action/impl/InventoryActionImpl.java | 40 -
.../saga/starter/DubboSagaProviderStarter.java | 53 -
.../saga/starter/DubboSagaTransactionStarter.java | 131 -
.../dubbo-saga-sample/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
.../main/resources/spring/seata-dubbo-provider.xml | 44 -
.../resources/spring/seata-dubbo-reference.xml | 41 -
.../src/main/resources/spring/seata-saga.xml | 59 -
.../src/main/resources/sql/h2_init.sql | 59 -
.../io/seata/samples/saga/SeataServerStarter.java | 45 -
saga/local-saga-sample/README.MD | 57 -
saga/local-saga-sample/pom.xml | 39 -
.../io/seata/samples/saga/ApplicationKeeper.java | 78 -
.../seata/samples/saga/action/BalanceAction.java | 45 -
.../seata/samples/saga/action/InventoryAction.java | 37 -
.../saga/action/impl/BalanceActionImpl.java | 55 -
.../saga/action/impl/InventoryActionImpl.java | 40 -
.../saga/starter/LocalSagaTransactionStarter.java | 136 -
.../local-saga-sample/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/spring/seata-saga.xml | 65 -
.../src/main/resources/sql/h2_init.sql | 59 -
.../io/seata/samples/saga/SeataServerStarter.java | 45 -
saga/pom.xml | 107 -
saga/sofarpc-saga-sample/README.MD | 54 -
saga/sofarpc-saga-sample/pom.xml | 154 -
.../io/seata/samples/saga/ApplicationKeeper.java | 78 -
.../seata/samples/saga/action/BalanceAction.java | 45 -
.../seata/samples/saga/action/InventoryAction.java | 37 -
.../saga/action/impl/BalanceActionImpl.java | 55 -
.../saga/action/impl/InventoryActionImpl.java | 40 -
.../provider/SofaRpcSagaProviderApplication.java | 55 -
.../starter/SofaRPCSagaTransactionApplication.java | 134 -
.../src/main/resources/application.properties | 28 -
.../src/main/resources/file.conf | 66 -
.../resources/provider/seata-sofarpc-provider.xml | 35 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/spring/seata-saga.xml | 42 -
.../resources/spring/seata-sofarpc-reference.xml | 31 -
.../src/main/resources/sql/h2_init.sql | 59 -
.../statelang/reduce_inventory_and_balance.json | 95 -
.../samples/saga/server/SeataServerStarter.java | 45 -
seata-samples-jit/pom.xml | 53 -
.../java/io/seata/samples/jit/AbstractStarter.java | 33 -
.../io/seata/samples/jit/ApplicationKeeper.java | 72 -
.../src/main/java/io/seata/samples/jit/Main.java | 57 -
.../io/seata/samples/jit/SeataServerStarter.java | 32 -
.../main/java/io/seata/samples/jit/Starter.java | 29 -
seata-spring-boot-starter-samples/README.md | 1229 --
seata-spring-boot-starter-samples/pom.xml | 183 -
.../samples-account-service/pom.xml | 52 -
.../account/AccountExampleApplication.java | 18 -
.../account/config/SeataDataSourceAutoConfig.java | 73 -
.../account/controller/TAccountController.java | 36 -
.../account/dubbo/AccountDubboServiceImpl.java | 31 -
.../integration/account/entity/TAccount.java | 60 -
.../integration/account/mapper/TAccountMapper.java | 26 -
.../account/service/ITAccountService.java | 23 -
.../account/service/TAccountServiceImpl.java | 37 -
.../src/main/resources/application.yml | 112 -
.../src/main/resources/mapper/TAccountMapper.xml | 26 -
.../samples-business-service/pom.xml | 46 -
.../call/BusinessExampleApplication.java | 18 -
.../call/controller/BusinessController.java | 49 -
.../integration/call/service/BusinessService.java | 28 -
.../call/service/BusinessServiceImpl.java | 107 -
.../src/main/resources/application.yml | 95 -
.../samples-common-service/pom.xml | 50 -
.../common/aop/GlobalExceptionHandler.java | 44 -
.../samples/integration/common/dto/AccountDTO.java | 45 -
.../integration/common/dto/BusinessDTO.java | 65 -
.../integration/common/dto/CommodityDTO.java | 54 -
.../samples/integration/common/dto/OrderDTO.java | 65 -
.../common/dubbo/AccountDubboService.java | 17 -
.../common/dubbo/OrderDubboService.java | 17 -
.../common/dubbo/StockDubboService.java | 17 -
.../integration/common/enums/RspStatusEnum.java | 50 -
.../common/exception/DefaultException.java | 35 -
.../integration/common/response/BaseResponse.java | 35 -
.../common/response/ObjectResponse.java | 20 -
.../samples-order-service/pom.xml | 47 -
.../integration/order/OrderExampleApplication.java | 18 -
.../order/config/SeataDataSourceAutoConfig.java | 73 -
.../order/controller/TOrderController.java | 36 -
.../order/dubbo/OrderDubboServiceImpl.java | 31 -
.../samples/integration/order/entity/TOrder.java | 88 -
.../integration/order/mapper/TOrderMapper.java | 25 -
.../integration/order/service/ITOrderService.java | 23 -
.../order/service/TOrderServiceImpl.java | 73 -
.../src/main/resources/application.yml | 111 -
.../src/main/resources/mapper/TOrderMapper.xml | 30 -
.../samples-stock-service/pom.xml | 46 -
.../integration/stock/StockExampleApplication.java | 18 -
.../stock/config/SeataDataSourceAutoConfig.java | 73 -
.../stock/controller/TStockController.java | 39 -
.../stock/dubbo/StockDubboServiceImpl.java | 31 -
.../samples/integration/stock/entity/TStock.java | 70 -
.../integration/stock/mapper/TStockMapper.java | 25 -
.../integration/stock/service/ITStockService.java | 21 -
.../stock/service/TStockServiceImpl.java | 37 -
.../src/main/resources/application.yml | 111 -
.../src/main/resources/mapper/TStorageMapper.xml | 28 -
seata-spring-boot-starter-samples/sql/db_seata.sql | 44 -
seata-xa/README.md | 93 -
seata-xa/account-xa/pom.xml | 14 -
.../java/io/seata/sample/AccountXAApplication.java | 14 -
.../sample/AccountXADataSourceConfiguration.java | 43 -
.../seata/sample/controller/AccountController.java | 28 -
.../io/seata/sample/service/AccountService.java | 34 -
.../src/main/resources/application.properties | 6 -
seata-xa/account-xa/src/main/resources/file.conf | 66 -
.../account-xa/src/main/resources/registry.conf | 79 -
seata-xa/business-xa/pom.xml | 14 -
.../io/seata/sample/BusinessXAApplication.java | 15 -
.../sample/BusinessXADataSourceConfiguration.java | 25 -
.../src/main/java/io/seata/sample/TestDatas.java | 6 -
.../sample/controller/BusinessController.java | 32 -
.../io/seata/sample/feign/OrderFeignClient.java | 14 -
.../io/seata/sample/feign/StockFeignClient.java | 13 -
.../io/seata/sample/service/BusinessService.java | 80 -
.../src/main/resources/application.properties | 7 -
seata-xa/business-xa/src/main/resources/file.conf | 66 -
.../business-xa/src/main/resources/registry.conf | 79 -
seata-xa/order-xa/pom.xml | 14 -
.../java/io/seata/sample/OrderXAApplication.java | 15 -
.../sample/OrderXADataSourceConfiguration.java | 35 -
.../seata/sample/controller/OrderController.java | 29 -
.../io/seata/sample/feign/AccountFeignClient.java | 11 -
.../java/io/seata/sample/service/OrderService.java | 42 -
.../src/main/resources/application.properties | 7 -
seata-xa/order-xa/src/main/resources/file.conf | 66 -
seata-xa/order-xa/src/main/resources/registry.conf | 79 -
seata-xa/pom.xml | 190 -
seata-xa/sql/all_in_one.sql | 29 -
seata-xa/stock-xa/pom.xml | 14 -
.../java/io/seata/sample/StockXAApplication.java | 13 -
.../sample/StockXADataSourceConfiguration.java | 35 -
.../seata/sample/controller/StockController.java | 28 -
.../java/io/seata/sample/service/StockService.java | 27 -
.../src/main/resources/application.properties | 6 -
seata-xa/stock-xa/src/main/resources/file.conf | 66 -
seata-xa/stock-xa/src/main/resources/registry.conf | 79 -
spring-cloud-alibaba-samples/README.md | 32 -
spring-cloud-alibaba-samples/doc/test.sql | 18 -
spring-cloud-alibaba-samples/pom.xml | 191 -
spring-cloud-alibaba-samples/sca-common/pom.xml | 28 -
.../io/seata/samples/sca/common/domain/TbDemo.java | 39 -
.../io/seata/samples/sca/common/domain/TbUser.java | 39 -
.../sca/common/dubbo/api/DubboEchoService.java | 24 -
.../samples/sca/common/dubbo/api/UserService.java | 27 -
spring-cloud-alibaba-samples/sca-customer/pom.xml | 45 -
.../io/seata/samples/sca/customer/CustomerApp.java | 40 -
.../customer/controller/CustomerController.java | 81 -
.../sca/customer/controller/DemoController.java | 62 -
.../sca/customer/feign/ProviderFeignService.java | 29 -
.../samples/sca/customer/mapper/TbDemoMapper.java | 33 -
.../sca/customer/service/TbDemoService.java | 40 -
.../src/main/resources/application.yml | 41 -
.../src/main/resources/config/generatorConfig.xml | 50 -
.../resources/config/mybatisGenerator.properties | 10 -
.../sca-customer/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/TbDemoMapper.xml | 71 -
.../sca-customer/src/main/resources/registry.conf | 79 -
.../seata/samples/genarator/CustomerGenerator.java | 41 -
.../java/io/seata/samples/genarator/Generator.java | 51 -
.../src/test/resources/config/generatorConfig.xml | 51 -
.../resources/config/mybatisGenerator.properties | 10 -
spring-cloud-alibaba-samples/sca-provider/pom.xml | 23 -
.../io/seata/samples/sca/provider/ProviderApp.java | 36 -
.../provider/controller/ProviderController.java | 31 -
.../sca/provider/dubbo/DubboEchoServiceImpl.java | 31 -
.../sca/provider/dubbo/UserServiceImpl.java | 49 -
.../samples/sca/provider/mapper/TbUserMapper.java | 32 -
.../src/main/resources/application.yml | 46 -
.../sca-provider/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/TbUserMapper.xml | 71 -
.../sca-provider/src/main/resources/registry.conf | 79 -
.../seata/samples/generator/CustomerGenerator.java | 41 -
.../java/io/seata/samples/generator/Generator.java | 51 -
.../src/test/resources/config/generatorConfig.xml | 51 -
.../resources/config/mybatisGenerator.properties | 10 -
springboot-dubbo-seata-zk/README.md | 1590 ---
springboot-dubbo-seata-zk/pom.xml | 193 -
springboot-dubbo-seata-zk/samples-account/pom.xml | 52 -
.../account/AccountExampleApplication.java | 20 -
.../integration/account/SimpleZkClient.java | 136 -
.../account/config/SeataDataSourceAutoConfig.java | 73 -
.../account/controller/TAccountController.java | 36 -
.../account/dubbo/AccountDubboServiceImpl.java | 30 -
.../integration/account/entity/TAccount.java | 60 -
.../integration/account/mapper/TAccountMapper.java | 19 -
.../account/service/ITAccountService.java | 23 -
.../account/service/TAccountServiceImpl.java | 37 -
.../io.seata.discovery.registry.RegistryProvider | 1 -
.../src/main/resources/application.yml | 107 -
.../src/main/resources/mapper/TAccountMapper.xml | 26 -
springboot-dubbo-seata-zk/samples-business/pom.xml | 46 -
.../call/BusinessExampleApplication.java | 18 -
.../seata/samples/integration/call/ZkDataInit.java | 65 -
.../call/controller/BusinessController.java | 49 -
.../integration/call/service/BusinessService.java | 28 -
.../call/service/BusinessServiceImpl.java | 106 -
.../io.seata.discovery.registry.RegistryProvider | 1 -
.../src/main/resources/application.yml | 85 -
.../src/main/resources/zk-config.properties | 71 -
springboot-dubbo-seata-zk/samples-common/pom.xml | 50 -
.../common/ZookeeperRegisterServiceImpl.java | 292 -
.../common/ZookeeperRegistryProvider.java | 16 -
.../common/aop/GlobalExceptionHandler.java | 44 -
.../samples/integration/common/dto/AccountDTO.java | 45 -
.../integration/common/dto/BusinessDTO.java | 65 -
.../integration/common/dto/CommodityDTO.java | 54 -
.../samples/integration/common/dto/OrderDTO.java | 65 -
.../common/dubbo/AccountDubboService.java | 17 -
.../common/dubbo/OrderDubboService.java | 17 -
.../common/dubbo/StorageDubboService.java | 17 -
.../integration/common/enums/RspStatusEnum.java | 50 -
.../common/exception/DefaultException.java | 35 -
.../integration/common/response/BaseResponse.java | 35 -
.../common/response/ObjectResponse.java | 20 -
springboot-dubbo-seata-zk/samples-order/pom.xml | 47 -
.../integration/order/OrderExampleApplication.java | 20 -
.../order/config/SeataDataSourceAutoConfig.java | 73 -
.../order/controller/TOrderController.java | 36 -
.../order/dubbo/OrderDubboServiceImpl.java | 30 -
.../samples/integration/order/entity/TOrder.java | 88 -
.../integration/order/mapper/TOrderMapper.java | 25 -
.../integration/order/service/ITOrderService.java | 23 -
.../order/service/TOrderServiceImpl.java | 72 -
.../io.seata.discovery.registry.RegistryProvider | 1 -
.../src/main/resources/application.yml | 102 -
.../src/main/resources/mapper/TOrderMapper.xml | 30 -
springboot-dubbo-seata-zk/samples-storage/pom.xml | 46 -
.../storage/StorageExampleApplication.java | 20 -
.../storage/config/SeataDataSourceAutoConfig.java | 73 -
.../storage/controller/TStorageController.java | 39 -
.../storage/dubbo/StorageDubboServiceImpl.java | 30 -
.../integration/storage/entity/TStorage.java | 70 -
.../integration/storage/mapper/TStorageMapper.java | 25 -
.../storage/service/ITStorageService.java | 21 -
.../storage/service/TStorageServiceImpl.java | 37 -
.../io.seata.discovery.registry.RegistryProvider | 1 -
.../src/main/resources/application.yml | 102 -
.../src/main/resources/mapper/TStorageMapper.xml | 28 -
springboot-dubbo-seata-zk/sql/db_seata.sql | 102 -
springboot-dubbo-seata/README.md | 92 -
springboot-dubbo-seata/pom.xml | 162 -
springboot-dubbo-seata/samples-account/pom.xml | 106 -
.../account/AccountExampleApplication.java | 38 -
.../account/config/SeataAutoConfig.java | 115 -
.../account/controller/TAccountController.java | 61 -
.../account/dubbo/AccountDubboServiceImpl.java | 44 -
.../integration/account/entity/TAccount.java | 74 -
.../integration/account/mapper/TAccountMapper.java | 35 -
.../account/service/ITAccountService.java | 39 -
.../account/service/TAccountServiceImpl.java | 61 -
.../src/main/resources/application.properties | 22 -
.../samples-account/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/TAccountMapper.xml | 31 -
.../src/main/resources/registry.conf | 79 -
springboot-dubbo-seata/samples-business/pom.xml | 94 -
.../call/BusinessExampleApplication.java | 34 -
.../integration/call/config/SeataAutoConfig.java | 39 -
.../call/controller/BusinessController.java | 56 -
.../integration/call/service/BusinessService.java | 29 -
.../call/service/BusinessServiceImpl.java | 86 -
.../src/main/resources/application.properties | 16 -
.../samples-business/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
springboot-dubbo-seata/samples-common/pom.xml | 49 -
.../common/aop/GlobalExceptionHandler.java | 59 -
.../samples/integration/common/dto/AccountDTO.java | 60 -
.../integration/common/dto/BusinessDTO.java | 80 -
.../integration/common/dto/CommodityDTO.java | 69 -
.../samples/integration/common/dto/OrderDTO.java | 80 -
.../common/dubbo/AccountDubboService.java | 32 -
.../common/dubbo/OrderDubboService.java | 32 -
.../common/dubbo/StockDubboService.java | 32 -
.../integration/common/enums/RspStatusEnum.java | 65 -
.../common/exception/DefaultException.java | 50 -
.../integration/common/response/BaseResponse.java | 50 -
.../common/response/ObjectResponse.java | 34 -
springboot-dubbo-seata/samples-order/pom.xml | 110 -
.../integration/order/OrderExampleApplication.java | 36 -
.../integration/order/config/SeataAutoConfig.java | 111 -
.../order/controller/TOrderController.java | 54 -
.../order/dubbo/OrderDubboServiceImpl.java | 44 -
.../samples/integration/order/entity/TOrder.java | 102 -
.../integration/order/mapper/TOrderMapper.java | 39 -
.../integration/order/service/ITOrderService.java | 37 -
.../order/service/TOrderServiceImpl.java | 87 -
.../src/main/resources/application.properties | 22 -
.../samples-order/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/TOrderMapper.xml | 30 -
.../samples-order/src/main/resources/registry.conf | 79 -
springboot-dubbo-seata/samples-stock/pom.xml | 110 -
.../integration/stock/StockExampleApplication.java | 36 -
.../integration/stock/config/SeataAutoConfig.java | 111 -
.../stock/controller/TStockController.java | 53 -
.../stock/dubbo/StockDubboServiceImpl.java | 44 -
.../samples/integration/stock/entity/TStock.java | 84 -
.../integration/stock/mapper/TStockMapper.java | 39 -
.../integration/stock/service/ITStockService.java | 35 -
.../stock/service/TStockServiceImpl.java | 51 -
.../src/main/resources/application.properties | 22 -
.../samples-stock/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/TStorageMapper.xml | 28 -
.../samples-stock/src/main/resources/registry.conf | 79 -
springboot-dubbo-seata/sql/db_seata.sql | 101 -
springboot-mybatis/pom.xml | 124 -
springboot-mybatis/sbm-account-service/pom.xml | 46 -
.../SpringbootMybatisAccountApplication.java | 29 -
.../samples/account/config/DataSourceConfig.java | 47 -
.../samples/account/config/RestTemplateConfig.java | 30 -
.../account/controller/AccountController.java | 39 -
.../seata/samples/account/persistence/Account.java | 50 -
.../samples/account/persistence/AccountMapper.java | 28 -
.../samples/account/service/AccountService.java | 43 -
.../src/main/resources/application.yml | 117 -
.../src/main/resources/logback.xml | 18 -
.../src/main/resources/mapper/AccountMapper.xml | 22 -
springboot-mybatis/sbm-business-service/pom.xml | 33 -
.../SpringbootMybatisBusinessApplication.java | 29 -
.../seata/samples/business/client/OrderClient.java | 37 -
.../seata/samples/business/client/StockClient.java | 38 -
.../business/config/RestTemplateConfig.java | 30 -
.../business/controller/BusinessController.java | 59 -
.../samples/business/service/BusinessService.java | 50 -
.../src/main/resources/application.yml | 110 -
.../src/main/resources/logback.xml | 16 -
springboot-mybatis/sbm-common-service/pom.xml | 73 -
.../io/seata/samples/common/SeataProperties.java | 34 -
.../config/SeataRestTemplateAutoConfiguration.java | 61 -
.../seata/samples/common/filter/SeataFilter.java | 60 -
.../interceptor/SeataRestTemplateInterceptor.java | 42 -
springboot-mybatis/sbm-order-service/pom.xml | 46 -
.../order/SpringbootMybatisOrderApplication.java | 29 -
.../seata/samples/order/client/AccountClient.java | 38 -
.../samples/order/config/DataSourceConfig.java | 47 -
.../samples/order/config/RestTemplateConfig.java | 30 -
.../samples/order/controller/OrderController.java | 39 -
.../io/seata/samples/order/persistence/Order.java | 70 -
.../samples/order/persistence/OrderMapper.java | 25 -
.../seata/samples/order/service/OrderService.java | 47 -
.../src/main/resources/application.yml | 117 -
.../src/main/resources/logback.xml | 18 -
.../src/main/resources/mapper/OrderMapper.xml | 18 -
springboot-mybatis/sbm-stock-service/pom.xml | 47 -
.../stock/SpringbootMybatisStockApplication.java | 29 -
.../samples/stock/config/DataSourceConfig.java | 47 -
.../samples/stock/config/RestTemplateConfig.java | 30 -
.../samples/stock/controller/StockController.java | 66 -
.../io/seata/samples/stock/persistence/Stock.java | 48 -
.../samples/stock/persistence/StockMapper.java | 37 -
.../seata/samples/stock/service/StockService.java | 136 -
.../src/main/resources/application.yml | 118 -
.../src/main/resources/logback.xml | 18 -
.../src/main/resources/mapper/StorageMapper.xml | 49 -
springboot-mybatis/sql/all_in_one.sql | 97 -
springboot-shardingsphere-seata/README.md | 58 -
springboot-shardingsphere-seata/pom.xml | 241 -
.../shardingsphere-seata-business/pom.xml | 134 -
.../ShardingsphereSeataBusinessApplication.java | 40 -
.../config/GlobalTransactionScanner.java | 295 -
.../config/MybatisPlusAutoConfig.java | 252 -
.../shardingsphere/config/MybatisPlusConfig.java | 58 -
.../samples/shardingsphere/config/SeataConfig.java | 31 -
.../controller/TestShardingSphereSeata.java | 37 -
.../shardingsphere/modules/entity/OrderEntity.java | 68 -
.../modules/entity/OrderItemEntity.java | 78 -
.../modules/mapper/OrderItemMapper.java | 25 -
.../shardingsphere/modules/mapper/OrderMapper.java | 25 -
.../modules/mock/IOrderServiceMockImpl.java | 28 -
.../modules/service/IBusinessService.java | 20 -
.../modules/service/IOrderItemService.java | 23 -
.../modules/service/IOrderService.java | 23 -
.../modules/service/impl/BusinessServiceImpl.java | 47 -
.../src/main/resources/META-INF/spring.factories | 3 -
.../src/main/resources/application.yml | 148 -
.../src/main/resources/file.conf | 66 -
.../src/main/resources/logback.xml | 54 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/seata.conf | 21 -
.../main/resources/sql/demo_ds_0 20190819 1012.sql | 145 -
.../main/resources/sql/demo_ds_1 20190819 1012.sql | 145 -
...hardingsphereSeataBusinessApplicationTests.java | 31 -
.../shardingsphere-seata-order/pom.xml | 131 -
.../ShardingsphereSeataOederApplication.java | 41 -
.../config/GlobalTransactionScanner.java | 295 -
.../config/MybatisPlusAutoConfig.java | 252 -
.../shardingsphere/config/MybatisPlusConfig.java | 58 -
.../samples/shardingsphere/config/SeataConfig.java | 31 -
.../config/ShardingSpringBootConfiguration.java | 170 -
.../shardingsphere/modules/entity/OrderEntity.java | 68 -
.../modules/entity/OrderItemEntity.java | 78 -
.../modules/mapper/OrderItemMapper.java | 25 -
.../shardingsphere/modules/mapper/OrderMapper.java | 25 -
.../modules/service/IOrderItemService.java | 23 -
.../modules/service/IOrderService.java | 23 -
.../modules/service/impl/OrderItemServiceImpl.java | 29 -
.../modules/service/impl/OrderServiceImpl.java | 32 -
.../src/main/resources/META-INF/spring.factories | 3 -
.../src/main/resources/application.yml | 147 -
.../src/main/resources/file.conf | 66 -
.../src/main/resources/logback.xml | 54 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/seata.conf | 21 -
.../main/resources/sql/demo_ds_0 20190819 1012.sql | 144 -
.../main/resources/sql/demo_ds_1 20190819 1012.sql | 144 -
.../ShardingsphereSeataOederApplicationTests.java | 31 -
springboot/README.md | 28 -
springboot/pom.xml | 212 -
.../samples/springboot/SeataSpringbootApp.java | 50 -
.../springboot/config/DruidConfiguration.java | 105 -
.../springboot/config/SeataConfiguration.java | 43 -
.../samples/springboot/service/AssetService.java | 29 -
.../samples/springboot/service/AssignService.java | 31 -
.../springboot/service/impl/AssetServiceImpl.java | 59 -
.../springboot/service/impl/AssignServiceImpl.java | 59 -
.../seata/samples/springboot/sys/domain/Asset.java | 107 -
.../samples/springboot/sys/domain/AssetAssign.java | 222 -
.../springboot/sys/repository/AssetRepository.java | 27 -
.../sys/repository/AssignRepository.java | 30 -
.../samples/springboot/web/AssetController.java | 70 -
springboot/src/main/resources/application.yml | 45 -
springboot/src/main/resources/file.conf | 66 -
springboot/src/main/resources/logback.xml | 30 -
springboot/src/main/resources/registry.conf | 79 -
springboot/src/main/resources/sql/init_db.sql | 66 -
springcloud-eureka-feign-mybatis-seata/README.md | 437 -
.../account-server/pom.xml | 67 -
.../io/seata/sample/AccountServerApplication.java | 40 -
.../io/seata/sample/DataSourceConfiguration.java | 64 -
.../seata/sample/controller/AccountController.java | 49 -
.../main/java/io/seata/sample/dao/AccountDao.java | 34 -
.../main/java/io/seata/sample/entity/Account.java | 49 -
.../main/java/io/seata/sample/feign/OrderApi.java | 41 -
.../io/seata/sample/service/AccountService.java | 32 -
.../seata/sample/service/AccountServiceImpl.java | 63 -
.../account-server/src/main/resources/account.sql | 12 -
.../src/main/resources/application.yml | 34 -
.../account-server/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/AccountMapper.xml | 17 -
.../src/main/resources/registry.conf | 82 -
.../sample/AccountServerApplicationTests.java | 31 -
.../eureka-server/pom.xml | 57 -
.../io/seata/sample/EurekaServerApplication.java | 33 -
.../src/main/resources/application.yml | 14 -
.../seata/sample/EurekaServerApplicationTests.java | 31 -
.../order-server/pom.xml | 66 -
.../io/seata/sample/DataSourceConfiguration.java | 64 -
.../io/seata/sample/OrderServerApplication.java | 40 -
.../seata/sample/controller/OrderController.java | 65 -
.../main/java/io/seata/sample/dao/OrderDao.java | 46 -
.../main/java/io/seata/sample/entity/Order.java | 45 -
.../java/io/seata/sample/feign/AccountApi.java | 39 -
.../main/java/io/seata/sample/feign/StockApi.java | 37 -
.../java/io/seata/sample/service/OrderService.java | 43 -
.../io/seata/sample/service/OrderServiceImpl.java | 81 -
.../src/main/resources/application.yml | 36 -
.../order-server/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/OrderMapper.xml | 24 -
.../order-server/src/main/resources/order.sql | 14 -
.../order-server/src/main/resources/registry.conf | 82 -
.../seata/sample/OrderServerApplicationTests.java | 31 -
springcloud-eureka-feign-mybatis-seata/pom.xml | 102 -
.../storage-server/pom.xml | 60 -
.../io/seata/sample/DataSourceConfiguration.java | 64 -
.../io/seata/sample/StockServerApplication.java | 36 -
.../seata/sample/controller/StockController.java | 46 -
.../main/java/io/seata/sample/dao/StockDao.java | 35 -
.../main/java/io/seata/sample/entity/Stock.java | 47 -
.../java/io/seata/sample/service/StockService.java | 31 -
.../io/seata/sample/service/StockServiceImpl.java | 48 -
.../src/main/resources/application.yml | 28 -
.../storage-server/src/main/resources/file.conf | 66 -
.../src/main/resources/mapper/StorageMapper.xml | 17 -
.../src/main/resources/registry.conf | 82 -
.../storage-server/src/main/resources/storage.sql | 12 -
.../seata/sample/StockServerApplicationTests.java | 31 -
springcloud-eureka-seata/README.md | 12 -
springcloud-eureka-seata/account/pom.xml | 83 -
.../java/io/seata/sample/AccountApplication.java | 65 -
.../seata/sample/controller/AccountController.java | 38 -
.../io/seata/sample/service/AccountService.java | 35 -
.../src/main/resources/application.properties | 12 -
.../account/src/main/resources/file.conf | 66 -
.../account/src/main/resources/registry.conf | 80 -
springcloud-eureka-seata/all.sql | 40 -
springcloud-eureka-seata/bussiness/pom.xml | 79 -
.../java/io/seata/sample/BusinessApplication.java | 34 -
.../io/seata/sample/DataSourceConfiguration.java | 44 -
.../sample/controller/BusinessController.java | 64 -
.../io/seata/sample/feign/OrderFeignClient.java | 33 -
.../io/seata/sample/feign/StockFeignClient.java | 32 -
.../io/seata/sample/service/BusinessService.java | 82 -
.../src/main/resources/application.properties | 12 -
.../bussiness/src/main/resources/file.conf | 66 -
.../bussiness/src/main/resources/registry.conf | 79 -
springcloud-eureka-seata/eureka/pom.xml | 24 -
.../io/seata/sample/EurekaServerApplication.java | 32 -
.../src/main/resources/application.properties | 6 -
springcloud-eureka-seata/order/pom.xml | 87 -
.../java/io/seata/sample/OrderApplication.java | 65 -
.../seata/sample/controller/OrderController.java | 41 -
.../io/seata/sample/feign/UserFeignClient.java | 31 -
.../java/io/seata/sample/service/OrderService.java | 45 -
.../src/main/resources/application.properties | 13 -
.../order/src/main/resources/file.conf | 66 -
.../order/src/main/resources/registry.conf | 80 -
springcloud-eureka-seata/pom.xml | 179 -
springcloud-eureka-seata/stock/pom.xml | 84 -
.../java/io/seata/sample/StockApplication.java | 63 -
.../seata/sample/controller/StockController.java | 38 -
.../java/io/seata/sample/service/StockService.java | 36 -
.../src/main/resources/application.properties | 13 -
.../stock/src/main/resources/file.conf | 66 -
.../stock/src/main/resources/registry.conf | 79 -
springcloud-jpa-seata/README.md | 79 -
springcloud-jpa-seata/account-service/pom.xml | 63 -
.../java/io/seata/sample/AccountApplication.java | 16 -
.../io/seata/sample/config/DataSourceConfig.java | 38 -
.../seata/sample/controller/AccountController.java | 28 -
.../main/java/io/seata/sample/entity/Account.java | 46 -
.../io/seata/sample/repository/AccountDAO.java | 16 -
.../io/seata/sample/service/AccountService.java | 34 -
.../src/main/resources/application.properties | 8 -
.../account-service/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 89 -
springcloud-jpa-seata/business-service/pom.xml | 50 -
.../java/io/seata/sample/BusinessApplication.java | 15 -
.../sample/controller/BusinessController.java | 41 -
.../io/seata/sample/feign/OrderFeignClient.java | 20 -
.../io/seata/sample/feign/StockFeignClient.java | 19 -
.../io/seata/sample/service/BusinessService.java | 36 -
.../src/main/resources/application.properties | 4 -
.../business-service/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 89 -
springcloud-jpa-seata/order-service/pom.xml | 69 -
.../java/io/seata/sample/OrderApplication.java | 17 -
.../io/seata/sample/config/DataSourceConfig.java | 38 -
.../seata/sample/controller/OrderController.java | 27 -
.../main/java/io/seata/sample/entity/Order.java | 86 -
.../io/seata/sample/feign/AccountFeignClient.java | 20 -
.../java/io/seata/sample/repository/OrderDAO.java | 14 -
.../java/io/seata/sample/service/OrderService.java | 44 -
.../src/main/resources/application.properties | 8 -
.../order-service/src/main/resources/file.conf | 66 -
.../order-service/src/main/resources/registry.conf | 89 -
springcloud-jpa-seata/pom.xml | 180 -
springcloud-jpa-seata/sql/all_in_one.sql | 101 -
springcloud-jpa-seata/stock-service/pom.xml | 63 -
.../java/io/seata/sample/StockApplication.java | 15 -
.../io/seata/sample/config/DataSourceConfig.java | 38 -
.../seata/sample/controller/StockController.java | 25 -
.../main/java/io/seata/sample/entity/Stock.java | 44 -
.../java/io/seata/sample/repository/StockDAO.java | 16 -
.../java/io/seata/sample/service/StockService.java | 28 -
.../src/main/resources/application.properties | 8 -
.../stock-service/src/main/resources/file.conf | 66 -
.../stock-service/src/main/resources/registry.conf | 88 -
springcloud-nacos-seata/README.md | 181 -
springcloud-nacos-seata/order-service/pom.xml | 36 -
.../com/work/order/OrderServiceApplication.java | 33 -
.../com/work/order/controller/OrderController.java | 73 -
.../com/work/order/feign/AccountFeignClient.java | 39 -
.../com/work/order/feign/StockFeignClient.java | 37 -
.../src/main/java/com/work/order/model/Order.java | 48 -
.../java/com/work/order/repository/OrderDAO.java | 37 -
.../java/com/work/order/service/OrderService.java | 81 -
.../src/main/resources/application.properties | 12 -
.../order-service/src/main/resources/registry.conf | 89 -
springcloud-nacos-seata/pom.xml | 184 -
springcloud-nacos-seata/stock-service/pom.xml | 36 -
.../com/work/stock/StockServiceApplication.java | 33 -
.../com/work/stock/controller/StockController.java | 54 -
.../src/main/java/com/work/stock/entity/Stock.java | 41 -
.../java/com/work/stock/repository/StockDAO.java | 37 -
.../java/com/work/stock/service/StockService.java | 61 -
.../src/main/resources/application.properties | 12 -
.../stock-service/src/main/resources/registry.conf | 89 -
.../README.md | 226 -
.../pom.xml | 59 -
.../seata-order-sample/pom.xml | 68 -
.../src/main/java/io/seata/OrderApplication.java | 15 -
.../java/io/seata/order/client/ProductClient.java | 12 -
.../io/seata/order/controller/OrderController.java | 22 -
.../src/main/java/io/seata/order/entity/Order.java | 27 -
.../java/io/seata/order/mapper/OrderMapper.java | 6 -
.../java/io/seata/order/service/OrderService.java | 39 -
.../src/main/resources/application.properties | 39 -
.../src/main/resources/seata.conf | 4 -
.../seata-product-sample/pom.xml | 63 -
.../src/main/java/io/seata/ProductApplication.java | 13 -
.../product/controller/ProductController.java | 22 -
.../main/java/io/seata/product/entity/Product.java | 23 -
.../io/seata/product/mapper/ProductMapper.java | 11 -
.../io/seata/product/service/ProductService.java | 18 -
.../src/main/resources/application.properties | 60 -
.../src/main/resources/seata.conf | 4 -
.../sql-and-seataconfig/seata_order_0.sql | 95 -
.../sql-and-seataconfig/seata_order_1.sql | 101 -
.../sql-and-seataconfig/seata_product.sql | 63 -
style/copyright | 23 +-
tcc-sample/spring-dubbo-seata-tcc/pom.xml | 116 +
.../java/org/apache/seata/action/ResultHolder.java | 73 +
.../java/org/apache/seata/action/TccActionOne.java | 50 +
.../java/org/apache/seata/action/TccActionTwo.java | 56 +
.../apache/seata/action/impl/TccActionOneImpl.java | 47 +
.../apache/seata/action/impl/TccActionTwoImpl.java | 59 +
.../seata/service/TccTransactionService.java | 108 +
.../apache/seata/stater/TccConsumerStarter.java | 67 +
.../apache/seata/stater/TccProviderStarter.java | 56 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../main/resources/spring/seata-dubbo-provider.xml | 53 +
.../resources/spring/seata-dubbo-reference.xml | 54 +
tcc-sample/springboot-sofarpc-seata-tcc/pom.xml | 107 +
.../seata/SofaRPCTccTransactionApplication.java | 95 +
.../java/org/apache/seata/action/ResultHolder.java | 73 +
.../java/org/apache/seata/action/TccActionOne.java | 50 +
.../java/org/apache/seata/action/TccActionTwo.java | 56 +
.../apache/seata/action/impl/TccActionOneImpl.java | 52 +
.../apache/seata/action/impl/TccActionTwoImpl.java | 64 +
.../seata/service/TccTransactionService.java | 149 +
.../src/main/resources/application.properties | 21 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
tcc/dubbo-tcc-sample/README.MD | 64 -
tcc/dubbo-tcc-sample/pom.xml | 123 -
.../samples/tcc/dubbo/action/ResultHolder.java | 72 -
.../samples/tcc/dubbo/action/TccActionOne.java | 54 -
.../samples/tcc/dubbo/action/TccActionTwo.java | 60 -
.../tcc/dubbo/action/impl/TccActionOneImpl.java | 51 -
.../tcc/dubbo/action/impl/TccActionTwoImpl.java | 58 -
.../tcc/dubbo/service/TccTransactionService.java | 101 -
.../tcc/dubbo/starter/TccConsumerStarter.java | 73 -
.../tcc/dubbo/starter/TccProviderStarter.java | 52 -
tcc/dubbo-tcc-sample/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 82 -
.../main/resources/spring/seata-dubbo-provider.xml | 47 -
.../resources/spring/seata-dubbo-reference.xml | 51 -
.../src/main/resources/spring/seata-tcc.xml | 35 -
tcc/hsf-tcc-sample/1.png | Bin 63823 -> 0 bytes
tcc/hsf-tcc-sample/2.png | Bin 66498 -> 0 bytes
tcc/hsf-tcc-sample/3.png | Bin 37932 -> 0 bytes
tcc/hsf-tcc-sample/README.md | 80 -
tcc/hsf-tcc-sample/pom.xml | 112 -
.../java/io/seata/edas/carshop/IndexServlet.java | 55 -
.../java/io/seata/edas/carshop/StartListener.java | 41 -
.../java/io/seata/edas/tcc/action/ActionOne.java | 54 -
.../java/io/seata/edas/tcc/action/ActionTwo.java | 58 -
.../seata/edas/tcc/action/impl/ActionOneImpl.java | 48 -
.../seata/edas/tcc/action/impl/ActionTwoImpl.java | 55 -
.../edas/tcc/activity/ActivityServiceImpl.java | 65 -
tcc/hsf-tcc-sample/src/main/resources/file.conf | 11 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/spring/hsf-beans.xml | 41 -
.../src/main/webapp/WEB-INF/logging.properties | 6 -
tcc/hsf-tcc-sample/src/main/webapp/WEB-INF/web.xml | 36 -
.../test/java/io/seata/edas/MockSeataServer.java | 44 -
tcc/local-tcc-sample/README.MD | 60 -
tcc/local-tcc-sample/pom.xml | 39 -
.../io/seata/samples/tcc/ApplicationKeeper.java | 78 -
.../io/seata/samples/tcc/action/ResultHolder.java | 72 -
.../io/seata/samples/tcc/action/TccActionOne.java | 55 -
.../io/seata/samples/tcc/action/TccActionTwo.java | 56 -
.../samples/tcc/action/impl/TccActionOneImpl.java | 51 -
.../samples/tcc/action/impl/TccActionTwoImpl.java | 52 -
.../samples/tcc/service/TccTransactionService.java | 93 -
.../tcc/starter/LocalTccTransactionStarter.java | 111 -
tcc/local-tcc-sample/src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
.../src/main/resources/spring/seata-tcc.xml | 36 -
.../io/seata/samples/tcc/SeataServerStarter.java | 46 -
tcc/pom.xml | 118 -
tcc/sofarpc-tcc-sample/README.MD | 64 -
tcc/sofarpc-tcc-sample/pom.xml | 126 -
.../samples/tcc/sofarpc/ApplicationKeeper.java | 81 -
.../samples/tcc/sofarpc/action/ResultHolder.java | 57 -
.../samples/tcc/sofarpc/action/TccActionOne.java | 38 -
.../samples/tcc/sofarpc/action/TccActionTwo.java | 39 -
.../tcc/sofarpc/action/impl/TccActionOneImpl.java | 36 -
.../tcc/sofarpc/action/impl/TccActionTwoImpl.java | 37 -
.../tcc/sofarpc/service/TccTransactionService.java | 78 -
.../starter/SofaRPCTccTransactionApplication.java | 71 -
.../src/main/resources/application.properties | 20 -
.../src/main/resources/file.conf | 66 -
.../resources/provider/seata-sofarpc-provider.xml | 34 -
.../src/main/resources/provider/seata-tcc.xml | 36 -
.../src/main/resources/registry.conf | 79 -
.../resources/spring/seata-sofarpc-reference.xml | 34 -
.../src/main/resources/spring/seata-tcc.xml | 36 -
.../provider/SofaRpcTccProviderApplication.java | 40 -
.../samples/tcc/server/SeataServerStarter.java | 44 -
tcc/springboot-tcc-sample/README.MD | 64 -
tcc/springboot-tcc-sample/pom.xml | 171 -
.../tcc/springboot/dubbo/ApplicationKeeper.java | 79 -
.../tcc/springboot/dubbo/action/ResultHolder.java | 57 -
.../tcc/springboot/dubbo/action/TccActionOne.java | 39 -
.../tcc/springboot/dubbo/action/TccActionTwo.java | 45 -
.../dubbo/action/impl/TccActionOneImpl.java | 36 -
.../dubbo/action/impl/TccActionTwoImpl.java | 43 -
.../dubbo/service/TccTransactionService.java | 86 -
.../SpringbootTccTransactionApplication.java | 71 -
.../src/main/resources/application.properties | 1 -
.../src/main/resources/file.conf | 66 -
.../resources/provider/seata-dubbo-provider.xml | 45 -
.../src/main/resources/provider/seata-tcc.xml | 35 -
.../src/main/resources/registry.conf | 79 -
.../resources/spring/seata-dubbo-reference.xml | 48 -
.../src/main/resources/spring/seata-tcc.xml | 35 -
.../provider/SpringbootTccProviderApplication.java | 40 -
.../samples/tcc/server/SeataServerStarter.java | 30 -
tcc/transfer-tcc-sample/README.MD | 71 -
tcc/transfer-tcc-sample/pom.xml | 135 -
.../samples/tcc/transfer/ApplicationKeeper.java | 78 -
.../tcc/transfer/action/FirstTccAction.java | 56 -
.../tcc/transfer/action/SecondTccAction.java | 57 -
.../transfer/action/impl/FirstTccActionImpl.java | 175 -
.../transfer/action/impl/SecondTccActionImpl.java | 170 -
.../tcc/transfer/activity/TransferService.java | 35 -
.../activity/impl/TransferServiceImpl.java | 72 -
.../seata/samples/tcc/transfer/dao/AccountDAO.java | 38 -
.../tcc/transfer/dao/impl/AccountDAOImpl.java | 65 -
.../samples/tcc/transfer/domains/Account.java | 65 -
.../tcc/transfer/env/TransferDataPrepares.java | 142 -
.../tcc/transfer/starter/TransferApplication.java | 146 -
.../transfer/starter/TransferProviderStarter.java | 54 -
.../resources/db-bean/from-datasource-bean.xml | 58 -
.../main/resources/db-bean/to-datasource-bean.xml | 57 -
.../src/main/resources/file.conf | 66 -
.../src/main/resources/registry.conf | 79 -
.../main/resources/spring/seata-dubbo-provider.xml | 40 -
.../resources/spring/seata-dubbo-reference.xml | 43 -
.../src/main/resources/spring/seata-tcc.xml | 37 -
.../src/main/resources/sqlmap/account.xml | 40 -
.../src/main/resources/sqlmap/sqlMapConfig.xml | 18 -
.../io/seata/samples/tcc/SeataServerStarter.java | 36 -
xa-sample/springboot-feign-seata-xa/pom.xml | 48 +
.../springboot-feign-seata-account/pom.xml | 111 +
.../SpringbootFeignSeataAccountApplication.java | 31 +
.../apache/seata/controller/AccountController.java | 47 +
.../org/apache/seata/service/AccountService.java | 23 +
.../seata/service/impl/AccountServiceImpl.java | 48 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 8 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-feign-seata-business/pom.xml | 111 +
.../SpringbootFeignSeataBusinessApplication.java | 31 +
.../seata/controller/BusinessController.java | 42 +
.../java/org/apache/seata/controller/TestData.java | 22 +
.../org/apache/seata/feign/OrderFeignClient.java | 30 +
.../org/apache/seata/feign/StockFeignClient.java | 29 +
.../org/apache/seata/service/BusinessService.java | 33 +
.../seata/service/impl/BusinessServiceImpl.java | 67 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 4 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-feign-seata-order/pom.xml | 111 +
.../SpringbootFeignSeataOrderApplication.java | 33 +
.../org/apache/seata/feign/AccountFeignClient.java | 28 +
.../org/apache/seata/service/OrderService.java | 29 +
.../seata/service/impl/OrderServiceImpl.java | 80 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 8 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
.../springboot-feign-seata-storage/pom.xml | 93 +
.../SpringbootFeignSeataStorageApplication.java | 31 +
.../apache/seata/controller/StockController.java | 46 +
.../org/apache/seata/service/StorageService.java | 36 +
.../seata/service/impl/StorageServiceImpl.java | 64 +
.../src/main/resources/all.sql | 56 +
.../src/main/resources/application.properties | 8 +
.../src/main/resources/file.conf | 126 +
.../src/main/resources/registry.conf | 124 +
1264 files changed, 14180 insertions(+), 70982 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8902b03d..3c090b4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,4 +61,5 @@ Thumbs.db
*/.idea/
*/.mvn/
+*/**/.mvn/
*/target/
diff --git a/README.md b/README.md
index 1f9e93dd..c7f8c593 100644
--- a/README.md
+++ b/README.md
@@ -1,57 +1,34 @@
-<img src="https://github.com/seata/seata-samples/blob/master/doc/img/seata.png" height="100" width="426">
-
-# 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](ht [...]
-
-## 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 f24eaee2..00000000
--- a/api/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>seata-samples</artifactId>
- <groupId>io.seata</groupId>
- <version>1.1.0</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>seata-samples-api</artifactId>
- <packaging>jar</packaging>
- <name>seata-samples-api ${project.version}</name>
-
- <dependencies>
- <dependency>
- <groupId>io.seata</groupId>
- <artifactId>seata-all</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${mysql-connector.version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- </dependencies>
-
-</project>
\ 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 b130ad9a..00000000
--- 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 1f447bd0..00000000
--- 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 2a0cafa1..00000000
--- 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 decaf5f6..00000000
--- 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 2bdfd0af..00000000
--- 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 d2e04746..00000000
--- 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 ff633e97..00000000
--- 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 164998b2..00000000
--- 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 6c8c67fa..00000000
--- 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 fbc8295b..00000000
--- 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<String, DataSource> 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 383bed6f..00000000
--- 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 b6ae6fb9..00000000
--- 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 c960c460..00000000
--- 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 81563eda..00000000
--- 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 c640e3a6..00000000
--- 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 00000000..77cbdcd1
--- /dev/null
+++ b/at-sample/at-api/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>at-api</artifactId>
+ <version>2.0.0</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <!-- log dependency start -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <!-- log dependency end -->
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-all</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.13.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+ </dependencies>
+</project>
\ 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 00000000..e1e7cb56
--- /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 00000000..8d75609a
--- /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 00000000..6a03c211
--- /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 00000000..afcf98dd
--- /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 00000000..b1437d33
--- /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 00000000..5d7617e1
--- /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 00000000..ce614fc7
--- /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 00000000..d66fce2c
--- /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 00000000..280038ef
--- /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 00000000..6e4d647e
--- /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<String, DataSource> 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 00000000..da78b71d
--- /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 00000000..a6974d7f
--- /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 00000000..e426f666
--- /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 00000000..060fd963
--- /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 00000000..a105dc3e
--- /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 00000000..563e247f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <!-- log dependency start -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <!-- log dependency end -->
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-all</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>5.3.20</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.13.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-x-discovery</artifactId>
+ <version>5.1.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ 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 00000000..4a39311d
--- /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 00000000..038ceee8
--- /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 00000000..e1039b75
--- /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 00000000..ec448c5f
--- /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 00000000..3c297f44
--- /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 00000000..7d4f8b36
--- /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 00000000..cb7ec238
--- /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 00000000..2a7708d6
--- /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 00000000..31ee831c
--- /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 00000000..e5e7e973
--- /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 00000000..ad1d6302
--- /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 00000000..6e5d68e2
--- /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 00000000..712324cf
--- /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 00000000..440ea161
--- /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 00000000..77ac8004
--- /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 00000000..8afe45de
--- /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 00000000..0abef900
--- /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 00000000..1090841f
--- /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 00000000..58a4a8a7
--- /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 00000000..e2a6e13c
--- /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 00000000..e624111a
--- /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 00000000..1358830e
--- /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 00000000..fca6ae8c
--- /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 00000000..a6974d7f
--- /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 00000000..b8d7fc9f
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..e5ad7d91
--- /dev/null
+++ b/at-sample/spring-seata/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-seata</artifactId>
+ <version>2.0.0</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <!-- log dependency start -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <!-- log dependency end -->
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-all</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>5.3.20</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.13.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+ </dependencies>
+</project>
\ 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 00000000..9729e4ab
--- /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 00000000..7d6687c4
--- /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 00000000..029f876a
--- /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 00000000..2e8a75da
--- /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 00000000..c6f16f41
--- /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 00000000..a360ca92
--- /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 00000000..0f68fad9
--- /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 00000000..ab3482ae
--- /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 00000000..a18e5aa8
--- /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 00000000..7aede43d
--- /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 00000000..8ee0cc42
--- /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 00000000..a6974d7f
--- /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 00000000..7aea7ea1
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..a5987d33
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.7.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata</name>
+ <description>springboot-dubbo-seata</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>springboot-dubbo-seata-common</module>
+ <module>springboot-dubbo-seata-storage</module>
+ <module>springboot-dubbo-seata-account</module>
+ <module>springboot-dubbo-seata-order</module>
+ <module>springboot-dubbo-seata-business</module>
+ </modules>
+
+ <properties>
+ <java.version>8</java.version>
+ </properties>
+</project>
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 00000000..0c303112
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <artifactId>springboot-dubbo-seata-account</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata-account</name>
+ <description>springboot-dubbo-seata-account</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-spring-boot-starter</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-x-discovery</artifactId>
+ <version>5.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jdbc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata-common</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 00000000..27ad4bb6
--- /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 00000000..d11c447d
--- /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 00000000..a6974d7f
--- /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 00000000..c89f20f9
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..5e916852
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <artifactId>springboot-dubbo-seata-business</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata-business</name>
+ <description>springboot-dubbo-seata-business</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-spring-boot-starter</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-x-discovery</artifactId>
+ <version>5.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata-common</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 00000000..22cd54d8
--- /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 00000000..c6f16f41
--- /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 00000000..e6e37409
--- /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 00000000..a6974d7f
--- /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 00000000..4dc07526
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..29392592
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <artifactId>springboot-dubbo-seata-common</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata-common</name>
+ <description>springboot-dubbo-seata-common</description>
+ <packaging>jar</packaging>
+</project>
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 00000000..6ae18eea
--- /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 00000000..fab053c8
--- /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 00000000..d0922e57
--- /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 00000000..7178780e
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <artifactId>springboot-dubbo-seata-order</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata-order</name>
+ <description>springboot-dubbo-seata-order</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-spring-boot-starter</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-x-discovery</artifactId>
+ <version>5.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jdbc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata-common</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 00000000..a86a30a5
--- /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 00000000..d0617e3b
--- /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 00000000..a6974d7f
--- /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 00000000..e192de12
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..2c3478b4
--- /dev/null
+++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata</artifactId>
+ <version>2.0.0</version>
+ </parent>
+ <artifactId>springboot-dubbo-seata-storage</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-dubbo-seata-storage</name>
+ <description>springboot-dubbo-seata-storage</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.7.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-spring-boot-starter</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-zookeeper-curator5</artifactId>
+ <version>3.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-x-discovery</artifactId>
+ <version>5.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jdbc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-dubbo-seata-common</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 00000000..d69a9c7f
--- /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 00000000..e53a2bb4
--- /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 00000000..a6974d7f
--- /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 00000000..33e291f1
--- /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 00000000..e426f666
--- /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 00000000..a105dc3e
--- /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 00000000..e073bade
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.7.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>springboot-mybatis-seata</artifactId>
+ <version>2.0.0</version>
+ <name>springboot-mybatis-seata</name>
+ <description>springboot-mybatis-seata</description>
+ <properties>
+ <java.version>8</java.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.seata</groupId>
+ <artifactId>seata-spring-boot-starter</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jdbc</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.42</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mybatis.spring.boot</groupId>
+ <artifactId>mybatis-spring-boot-starter</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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 00000000..d8a4255e
--- /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 00000000..fe972868
--- /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 00000000..78ba48cc
--- /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 00000000..814edc74
--- /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 00000000..443e2e33
--- /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<Storage> records);
+
+ int updateBatch(@Param("list") List<Long> 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 00000000..b8aecbea
--- /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 00000000..ad78960c
--- /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 00000000..fd939948
--- /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 00000000..2e8a75da
--- /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 00000000..c6f16f41
--- /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 00000000..a360ca92
--- /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 00000000..0f68fad9
--- /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 00000000..0af9a208
--- /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 00000000..a97ff2fc
--- /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 00000000..38a7f439
--- /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 00000000..cfe96d78
--- /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 00000000..a6974d7f
--- /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 00000000..61c3f524
--- /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 00000000..e426f666
--- /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 00000000..328d01d5
--- /dev/null
+++ b/at-sample/springboot-mybatis-seata/src/main/resources/mapper/AccountMapper.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="org.apache.seata.dao.AccountMapper">
+ <resultMap id="BaseResultMap" type="org.apache.seata.model.Account">
+ <id column="id" property="id" jdbcType="INTEGER"/>
+ <result column="user_id" property="userId" jdbcType="VARCHAR"/>
+ <result column="money" property="money" jdbcType="INTEGER"/>
+ </resultMap>
+
+ <select id="selectByUserId" resultType="org.apache.seata.model.Account">
+ select id, user_id, money
+ from account_tbl
+ WHERE user_id = #{userId}
+ </select>
+
+ <update id="updateById" parameterType="org.apache.seata.model.Account">
+ update account_tbl
+ set money = #{money,jdbcType=INTEGER}
+ where id = #{id}
... 84367 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org