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/10/25 08:37:47 UTC
(incubator-seata-samples) branch master updated: feat: add spring-dubbo-seata and spring-seata e2e cases in at-sample (#696)
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 3d20d3f7 feat: add spring-dubbo-seata and spring-seata e2e cases in at-sample (#696)
3d20d3f7 is described below
commit 3d20d3f79434cf149ef2acae37ed170e0bf01218
Author: A Cabbage <92...@qq.com>
AuthorDate: Fri Oct 25 16:37:43 2024 +0800
feat: add spring-dubbo-seata and spring-seata e2e cases in at-sample (#696)
---
at-sample/at-api/seata-e2e.yaml | 2 +-
.../spring-dubbo-seata/e2e-files/sqlsh/all.sql | 56 +++++++++
.../spring-dubbo-seata/e2e-files/success.yaml | 1 +
at-sample/spring-dubbo-seata/e2e-replace/file.conf | 126 +++++++++++++++++++++
at-sample/spring-dubbo-seata/pom.xml | 85 ++------------
.../seata-e2e.yaml | 52 +++++----
.../{ => spring-dubbo-seata-account}/pom.xml | 68 ++++++-----
.../seata/account/DubboAccountServiceStarter.java} | 26 ++---
.../account/config/DataSourceConfiguration.java | 60 ++++++++++
.../seata/account/config/DubboConfiguration.java | 65 +++++++++++
.../seata/account/config/SeataConfiguration.java | 45 ++++++++
.../account/service/impl/AccountServiceImpl.java | 46 ++++++++
.../src/main/resources/all.sql | 56 +++++++++
.../src/main/resources/application.properties | 18 +++
.../src/main/resources/file.conf | 126 +++++++++++++++++++++
.../src/main/resources/logback.xml | 13 +++
.../src/main/resources/registry.conf | 124 ++++++++++++++++++++
.../{ => spring-dubbo-seata-business}/pom.xml | 69 ++++++-----
.../business/DubboBusinessServiceTester.java} | 41 ++++---
.../seata/business/config/DubboConfiguration.java | 56 +++++++++
.../seata/business/config/SeataConfiguration.java | 45 ++++++++
.../business/service/impl/BusinessServiceImpl.java | 54 +++++++++
.../src/main/resources/all.sql | 56 +++++++++
.../src/main/resources/application.properties | 18 +++
.../src/main/resources/file.conf | 126 +++++++++++++++++++++
.../src/main/resources/logback.xml | 13 +++
.../src/main/resources/registry.conf | 124 ++++++++++++++++++++
.../spring-dubbo-seata-common/pom.xml | 20 ++++
.../main/java/org/apache/seata/e2e/E2EUtil.java | 25 ++++
.../org/apache/seata/service/AccountService.java | 27 +++++
.../org/apache/seata/service/BusinessService.java | 28 +++++
.../org/apache/seata/service/OrderService.java | 28 +++++
.../org/apache/seata/service/StorageService.java | 35 ++++++
.../{ => spring-dubbo-seata-order}/pom.xml | 68 ++++++-----
.../seata/order/DubboOrderServiceStarter.java} | 26 ++---
.../order/config/DataSourceConfiguration.java | 60 ++++++++++
.../seata/order/config/DubboConfiguration.java | 65 +++++++++++
.../seata/order/config/SeataConfiguration.java | 45 ++++++++
.../seata/order/service/impl/OrderServiceImpl.java | 79 +++++++++++++
.../src/main/resources/all.sql | 56 +++++++++
.../src/main/resources/application.properties | 18 +++
.../src/main/resources/file.conf | 126 +++++++++++++++++++++
.../src/main/resources/logback.xml | 13 +++
.../src/main/resources/registry.conf | 124 ++++++++++++++++++++
.../{ => spring-dubbo-seata-storage}/pom.xml | 68 ++++++-----
.../seata/storage/DubboStorageServiceStarter.java} | 26 ++---
.../storage/config/DataSourceConfiguration.java | 60 ++++++++++
.../seata/storage/config/DubboConfiguration.java | 65 +++++++++++
.../seata/storage/config/SeataConfiguration.java | 45 ++++++++
.../storage/service/impl/StorageServiceImpl.java | 61 ++++++++++
.../src/main/resources/all.sql | 56 +++++++++
.../src/main/resources/application.properties | 18 +++
.../src/main/resources/file.conf | 126 +++++++++++++++++++++
.../src/main/resources/logback.xml | 13 +++
.../src/main/resources/registry.conf | 124 ++++++++++++++++++++
.../src/main/resources/application.properties | 12 +-
at-sample/spring-seata/e2e-files/sqlsh/all.sql | 59 ++++++++++
at-sample/spring-seata/e2e-files/success.yaml | 1 +
.../e2e-replace/application.properties | 5 +
at-sample/spring-seata/e2e-replace/file.conf | 126 +++++++++++++++++++++
at-sample/spring-seata/pom.xml | 26 +++++
at-sample/{at-api => spring-seata}/seata-e2e.yaml | 14 +--
.../org/apache/seata/BusinessServiceTester.java | 18 ++-
.../main/java/org/apache/seata/e2e/E2EUtil.java | 25 ++++
at-sample/springboot-dubbo-seata/seata-e2e.yaml | 4 +-
.../org/apache/seata/builder/ImageBuilder.java | 6 +-
.../seata/controller/SkyWalkingController.java | 4 +-
67 files changed, 3085 insertions(+), 291 deletions(-)
diff --git a/at-sample/at-api/seata-e2e.yaml b/at-sample/at-api/seata-e2e.yaml
index 3e7f833d..cd77fd90 100644
--- a/at-sample/at-api/seata-e2e.yaml
+++ b/at-sample/at-api/seata-e2e.yaml
@@ -53,6 +53,6 @@ e2e:
# cases to verify
cases:
- - name: normal test rollback
+ - name: normal test success
invoke: 'docker exec test cat result.yaml'
verify: './e2e-files/rollback.yaml'
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/e2e-files/sqlsh/all.sql b/at-sample/spring-dubbo-seata/e2e-files/sqlsh/all.sql
new file mode 100644
index 00000000..a6974d7f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/e2e-files/sqlsh/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/e2e-files/success.yaml b/at-sample/spring-dubbo-seata/e2e-files/success.yaml
new file mode 100644
index 00000000..946b0e70
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/e2e-files/success.yaml
@@ -0,0 +1 @@
+{"res": "success"}
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/e2e-replace/file.conf b/at-sample/spring-dubbo-seata/e2e-replace/file.conf
new file mode 100644
index 00000000..cf823052
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/e2e-replace/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 = "seata: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/pom.xml b/at-sample/spring-dubbo-seata/pom.xml
index 015d43b3..74b317d8 100644
--- a/at-sample/spring-dubbo-seata/pom.xml
+++ b/at-sample/spring-dubbo-seata/pom.xml
@@ -25,80 +25,19 @@
<groupId>org.apache.seata</groupId>
<artifactId>spring-dubbo-seata</artifactId>
<version>2.1.0</version>
+ <name>spring-dubbo-seata</name>
+ <description>spring-dubbo-seata</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>spring-dubbo-seata-common</module>
+ <module>spring-dubbo-seata-storage</module>
+ <module>spring-dubbo-seata-account</module>
+ <module>spring-dubbo-seata-order</module>
+ <module>spring-dubbo-seata-business</module>
+ </modules>
<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>
+ <java.version>8</java.version>
</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.13</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>org.apache.seata</groupId>
- <artifactId>seata-all</artifactId>
- <version>2.1.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>8.0.28</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>3.1.11</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/springboot-dubbo-seata/seata-e2e.yaml b/at-sample/spring-dubbo-seata/seata-e2e.yaml
similarity index 70%
copy from at-sample/springboot-dubbo-seata/seata-e2e.yaml
copy to at-sample/spring-dubbo-seata/seata-e2e.yaml
index bf3f2510..6230965e 100644
--- a/at-sample/springboot-dubbo-seata/seata-e2e.yaml
+++ b/at-sample/spring-dubbo-seata/seata-e2e.yaml
@@ -1,5 +1,5 @@
e2e:
- scene_name: at-springboot-dubbo-seata
+ scene_name: at-spring-dubbo-seata
# retry config
retry:
max: 5
@@ -10,27 +10,28 @@ e2e:
# consume services
consumers:
# docker service name
- - name: springboot-dubbo-seata-business # this name should be the same as module name, it is indicated to be builded as an image
+ - name: spring-dubbo-seata-business # this name should be the same as module name, it is indicated to be builded as an image
# service params in a service of docker-compose service
docker_service:
- hostname: springboot-dubbo-seata-business
+ hostname: spring-dubbo-seata-business
restart: on-failure
container_name: test
depends_on:
- springboot-dubbo-seata-account:
+ spring-dubbo-seata-account:
condition: service_started
- springboot-dubbo-seata-storage:
+ spring-dubbo-seata-storage:
condition: service_started
- springboot-dubbo-seata-order:
+ spring-dubbo-seata-order:
condition: service_started
environment:
zookeeper.address: zookeeper
seata.address: seata
+ E2E_ENV: open
# provider service
providers:
- - name: springboot-dubbo-seata-account
+ - name: spring-dubbo-seata-account
docker_service:
- hostname: springboot-dubbo-seata-account
+ hostname: spring-dubbo-seata-account
restart: on-failure
depends_on:
zookeeper:
@@ -42,9 +43,10 @@ e2e:
mysql.address: mysqlAddress
mysql.user: user
seata.address: seata
- - name: springboot-dubbo-seata-order
+ E2E_ENV: open
+ - name: spring-dubbo-seata-order
docker_service:
- hostname: springboot-dubbo-seata-order
+ hostname: spring-dubbo-seata-order
restart: on-failure
depends_on:
zookeeper:
@@ -56,9 +58,10 @@ e2e:
mysql.address: mysqlAddress
mysql.user: user
seata.address: seata
- - name: springboot-dubbo-seata-storage
+ E2E_ENV: open
+ - name: spring-dubbo-seata-storage
docker_service:
- hostname: springboot-dubbo-seata-order
+ hostname: spring-dubbo-seata-order
restart: on-failure
depends_on:
zookeeper:
@@ -70,6 +73,7 @@ e2e:
mysql.address: mysqlAddress
mysql.user: user
seata.address: seata
+ E2E_ENV: open
# infrastructure services
infrastructures:
- name: mysql
@@ -104,7 +108,7 @@ e2e:
- name: zookeeper
docker_service:
hostname: zookeeper
- image: zookeeper:3.5.7
+ image: zookeeper:3.8.4
# ports:
# - "2181:2181"
healthcheck:
@@ -113,14 +117,18 @@ e2e:
timeout: 10s
retries: 3
+ replace:
+ - source: e2e-replace/file.conf
+ dest: spring-dubbo-seata-account/src/main/resources/file.conf
+ - source: e2e-replace/file.conf
+ dest: spring-dubbo-seata-business/src/main/resources/file.conf
+ - source: e2e-replace/file.conf
+ dest: spring-dubbo-seata-order/src/main/resources/file.conf
+ - source: e2e-replace/file.conf
+ dest: spring-dubbo-seata-storage/src/main/resources/file.conf
+
# cases to verify
cases:
- - name: rollback test
- # how to invoke the case
- invoke: 'docker exec test curl http://127.0.0.1:9991/testRollback'
- # the result of the case to expect be
- verify: './e2e-files/rollback.yaml'
-
- - name: commit test
- invoke: 'docker exec test curl http://127.0.0.1:9991/testCommit'
- verify: './e2e-files/commit.yaml'
\ No newline at end of file
+ - name: normal test success
+ invoke: 'docker exec test cat result.yaml'
+ verify: './e2e-files/success.yaml'
\ No newline at end of file
diff --git a/at-sample/spring-dubbo-seata/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml
similarity index 59%
copy from at-sample/spring-dubbo-seata/pom.xml
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml
index 015d43b3..3eb15b4f 100644
--- a/at-sample/spring-dubbo-seata/pom.xml
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml
@@ -1,30 +1,15 @@
-<?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">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.seata</groupId>
- <artifactId>spring-dubbo-seata</artifactId>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.1.0</version>
+ </parent>
+ <artifactId>spring-dubbo-seata-account</artifactId>
<version>2.1.0</version>
+ <name>spring-dubbo-seata-account</name>
+ <description>spring-dubbo-seata-account</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -99,6 +84,37 @@
<artifactId>curator-x-discovery</artifactId>
<version>5.1.0</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata-common</artifactId>
+ <version>2.1.0</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.seata.account.DubboAccountServiceStarter</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java
similarity index 67%
copy from at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java
index 6b44c46e..8b1db6cb 100644
--- a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/DubboAccountServiceStarter.java
@@ -14,24 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.seata;
+package org.apache.seata.account;
import org.apache.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
-import org.apache.seata.service.BusinessService;
+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.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-/**
- * @author wangte
- * Create At 2024/1/20
- */
-@ComponentScan
-@Configuration
+
@EnableAutoDataSourceProxy
-public class BusinessServiceTester {
+@EnableDubbo(scanBasePackages = {"org.apache.seata.account"})
+@ComponentScan(basePackages = {"org.apache.seata.account"})
+public class DubboAccountServiceStarter {
/**
* Enable PropertySource placeHolder
@@ -41,14 +37,8 @@ public class BusinessServiceTester {
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();
+ 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/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/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/spring-dubbo-seata-account/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/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/DubboConfiguration.java
new file mode 100644
index 00000000..9b400bbc
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/DubboConfiguration.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import static org.apache.seata.e2e.E2EUtil.isInE2ETest;
+
+/**
+ * @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();
+ if (isInE2ETest()) {
+ registryConfig.setAddress("zookeeper://zookeeper:2181");
+ } else {
+ 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/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/config/SeataConfiguration.java
new file mode 100644
index 00000000..cd43c1d0
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/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 org.apache.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/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/service/impl/AccountServiceImpl.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/java/org/apache/seata/account/service/impl/AccountServiceImpl.java
new file mode 100644
index 00000000..4458306b
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/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 org.apache.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/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/all.sql b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/all.sql
new file mode 100644
index 00000000..a6974d7f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/application.properties
new file mode 100644
index 00000000..6fcc8f60
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/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://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.account.username=${mysql.user:root}
+spring.datasource.account.password=${mysql.password:123456}
+spring.datasource.account.driverClassName=com.mysql.cj.jdbc.Driver
+# stock db config
+spring.datasource.stock.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.stock.username=${mysql.user:root}
+spring.datasource.stock.password=${mysql.password:123456}
+spring.datasource.stock.driverClassName=com.mysql.cj.jdbc.Driver
+# order db config
+spring.datasource.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.order.username=${mysql.user:root}
+spring.datasource.order.password=${mysql.password:123456}
+spring.datasource.order.driverClassName=com.mysql.cj.jdbc.Driver
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/file.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/file.conf
new file mode 100644
index 00000000..e426f666
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/logback.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/logback.xml
new file mode 100644
index 00000000..14ecfc13
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+</configuration>
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/registry.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/src/main/resources/registry.conf
new file mode 100644
index 00000000..a105dc3e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml
similarity index 59%
copy from at-sample/spring-dubbo-seata/pom.xml
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml
index 015d43b3..100ded33 100644
--- a/at-sample/spring-dubbo-seata/pom.xml
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml
@@ -1,30 +1,15 @@
-<?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">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.seata</groupId>
- <artifactId>spring-dubbo-seata</artifactId>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.1.0</version>
+ </parent>
+ <artifactId>spring-dubbo-seata-business</artifactId>
<version>2.1.0</version>
+ <name>spring-dubbo-seata-business</name>
+ <description>spring-dubbo-seata-business</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -99,6 +84,38 @@
<artifactId>curator-x-discovery</artifactId>
<version>5.1.0</version>
</dependency>
+
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata-common</artifactId>
+ <version>2.1.0</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.seata.business.DubboBusinessServiceTester</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java
similarity index 61%
copy from at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java
index 6b44c46e..ad628ec7 100644
--- a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/DubboBusinessServiceTester.java
@@ -14,24 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.seata;
+package org.apache.seata.business;
-import org.apache.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.seata.service.BusinessService;
+import org.apache.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
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
+import static org.apache.seata.e2e.E2EUtil.isInE2ETest;
+import static org.apache.seata.e2e.E2EUtil.writeE2EResFile;
+
@EnableAutoDataSourceProxy
-public class BusinessServiceTester {
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.business"})
+public class DubboBusinessServiceTester {
/**
* Enable PropertySource placeHolder
@@ -41,17 +40,27 @@ public class BusinessServiceTester {
return new PropertySourcesPlaceholderConfigurer();
}
- public static void main(String[] args) throws Exception {
- AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(BusinessServiceTester.class);
+ 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 thread = new Thread(() -> {
+ businessService.purchase("U100001", "C00321", 2);});
+ String outPutRes = "{\"res\": \"success\"}";
+ try {
+ businessService.purchase("U100001", "C00321", 2);
+ if (isInE2ETest()) {
+ writeE2EResFile(outPutRes);
+ }
+ } catch (Exception e) {
+ if ("random exception mock!".equals(e.getMessage()) && isInE2ETest()) {
+ writeE2EResFile(outPutRes);
+ }
+ throw new RuntimeException(e);
+ }
thread.start();
- thread.join();
//keep run
Thread.currentThread().join();
}
-
}
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/config/DubboConfiguration.java
new file mode 100644
index 00000000..fbcd74aa
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/config/DubboConfiguration.java
@@ -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.
+ */
+package org.apache.seata.business.config;
+
+import org.apache.dubbo.config.ApplicationConfig;
+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;
+
+import static org.apache.seata.e2e.E2EUtil.isInE2ETest;
+
+/**
+ * @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();
+ if (isInE2ETest()) {
+ registryConfig.setAddress("zookeeper://zookeeper:2181");
+ } else {
+ registryConfig.setAddress("zookeeper://localhost:2181");
+ }
+ return registryConfig;
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/config/SeataConfiguration.java
new file mode 100644
index 00000000..ca0229b1
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/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 org.apache.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/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/service/impl/BusinessServiceImpl.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/java/org/apache/seata/business/service/impl/BusinessServiceImpl.java
new file mode 100644
index 00000000..147f0d69
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/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 org.apache.seata.core.context.RootContext;
+import org.apache.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/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/all.sql b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/all.sql
new file mode 100644
index 00000000..a6974d7f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/application.properties
new file mode 100644
index 00000000..6fcc8f60
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/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://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.account.username=${mysql.user:root}
+spring.datasource.account.password=${mysql.password:123456}
+spring.datasource.account.driverClassName=com.mysql.cj.jdbc.Driver
+# stock db config
+spring.datasource.stock.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.stock.username=${mysql.user:root}
+spring.datasource.stock.password=${mysql.password:123456}
+spring.datasource.stock.driverClassName=com.mysql.cj.jdbc.Driver
+# order db config
+spring.datasource.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.order.username=${mysql.user:root}
+spring.datasource.order.password=${mysql.password:123456}
+spring.datasource.order.driverClassName=com.mysql.cj.jdbc.Driver
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/file.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/file.conf
new file mode 100644
index 00000000..e426f666
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/logback.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/logback.xml
new file mode 100644
index 00000000..14ecfc13
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+</configuration>
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/registry.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/src/main/resources/registry.conf
new file mode 100644
index 00000000..a105dc3e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-common/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/pom.xml
new file mode 100644
index 00000000..f3b8ba6c
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/pom.xml
@@ -0,0 +1,20 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.1.0</version>
+ </parent>
+ <artifactId>spring-dubbo-seata-common</artifactId>
+ <version>2.1.0</version>
+ <name>spring-dubbo-seata-common</name>
+ <description>spring-dubbo-seata-common</description>
+
+ <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>
+</project>
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/e2e/E2EUtil.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/e2e/E2EUtil.java
new file mode 100644
index 00000000..80c76bc4
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/e2e/E2EUtil.java
@@ -0,0 +1,25 @@
+package org.apache.seata.e2e;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+
+/**
+ * @author jingliu_xiong@foxmail.com
+ */
+public class E2EUtil {
+ public static void writeE2EResFile(String outPutRes) {
+ try {
+ Files.write(Paths.get("result.yaml"), outPutRes.getBytes());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static boolean isInE2ETest() {
+ Map<String, String> envs = System.getenv();
+ String env = envs.getOrDefault("E2E_ENV", "");
+ return "open".equals(env);
+ }
+}
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java
new file mode 100644
index 00000000..0fae4cfe
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/AccountService.java
@@ -0,0 +1,27 @@
+package org.apache.seata.service;/*
+ * 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.
+ */
+
+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/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/BusinessService.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/BusinessService.java
new file mode 100644
index 00000000..d1408550
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/BusinessService.java
@@ -0,0 +1,28 @@
+package org.apache.seata.service;/*
+ * 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.
+ */
+
+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/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java
new file mode 100644
index 00000000..f354d900
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/OrderService.java
@@ -0,0 +1,28 @@
+package org.apache.seata.service;/*
+ * 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.
+ */
+
+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/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java
new file mode 100644
index 00000000..6ab6e110
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/src/main/java/org/apache/seata/service/StorageService.java
@@ -0,0 +1,35 @@
+package org.apache.seata.service;/*
+ * 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.
+ */
+
+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/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml
similarity index 59%
copy from at-sample/spring-dubbo-seata/pom.xml
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml
index 015d43b3..90387a25 100644
--- a/at-sample/spring-dubbo-seata/pom.xml
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml
@@ -1,30 +1,15 @@
-<?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">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.seata</groupId>
- <artifactId>spring-dubbo-seata</artifactId>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.1.0</version>
+ </parent>
+ <artifactId>spring-dubbo-seata-order</artifactId>
<version>2.1.0</version>
+ <name>spring-dubbo-seata-order</name>
+ <description>spring-dubbo-seata-order</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -99,6 +84,37 @@
<artifactId>curator-x-discovery</artifactId>
<version>5.1.0</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata-common</artifactId>
+ <version>2.1.0</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.seata.order.DubboOrderServiceStarter</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java
similarity index 67%
copy from at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java
index 6b44c46e..9ed85e50 100644
--- a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/DubboOrderServiceStarter.java
@@ -14,24 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.seata;
+package org.apache.seata.order;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.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 {
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.order"})
+public class DubboOrderServiceStarter {
/**
* Enable PropertySource placeHolder
@@ -41,14 +37,8 @@ public class BusinessServiceTester {
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();
+ 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/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/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/spring-dubbo-seata-order/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/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/DubboConfiguration.java
new file mode 100644
index 00000000..e8399b2e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/DubboConfiguration.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import static org.apache.seata.e2e.E2EUtil.isInE2ETest;
+
+/**
+ * @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();
+ if (isInE2ETest()) {
+ registryConfig.setAddress("zookeeper://zookeeper:2181");
+ } else {
+ 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/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/config/SeataConfiguration.java
new file mode 100644
index 00000000..dc81ef86
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/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 org.apache.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/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/service/impl/OrderServiceImpl.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/java/org/apache/seata/order/service/impl/OrderServiceImpl.java
new file mode 100644
index 00000000..4886340c
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/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 org.apache.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/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/all.sql b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/all.sql
new file mode 100644
index 00000000..a6974d7f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/application.properties
new file mode 100644
index 00000000..6fcc8f60
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/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://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.account.username=${mysql.user:root}
+spring.datasource.account.password=${mysql.password:123456}
+spring.datasource.account.driverClassName=com.mysql.cj.jdbc.Driver
+# stock db config
+spring.datasource.stock.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.stock.username=${mysql.user:root}
+spring.datasource.stock.password=${mysql.password:123456}
+spring.datasource.stock.driverClassName=com.mysql.cj.jdbc.Driver
+# order db config
+spring.datasource.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.order.username=${mysql.user:root}
+spring.datasource.order.password=${mysql.password:123456}
+spring.datasource.order.driverClassName=com.mysql.cj.jdbc.Driver
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/file.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/file.conf
new file mode 100644
index 00000000..e426f666
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/logback.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/logback.xml
new file mode 100644
index 00000000..14ecfc13
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+</configuration>
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/registry.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/src/main/resources/registry.conf
new file mode 100644
index 00000000..a105dc3e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml
similarity index 59%
copy from at-sample/spring-dubbo-seata/pom.xml
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml
index 015d43b3..4f29f85e 100644
--- a/at-sample/spring-dubbo-seata/pom.xml
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml
@@ -1,30 +1,15 @@
-<?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">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.seata</groupId>
- <artifactId>spring-dubbo-seata</artifactId>
+ <parent>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata</artifactId>
+ <version>2.1.0</version>
+ </parent>
+ <artifactId>spring-dubbo-seata-storage</artifactId>
<version>2.1.0</version>
+ <name>spring-dubbo-seata-storage</name>
+ <description>spring-dubbo-seata-storage</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -99,6 +84,37 @@
<artifactId>curator-x-discovery</artifactId>
<version>5.1.0</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>spring-dubbo-seata-common</artifactId>
+ <version>2.1.0</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.seata.storage.DubboStorageServiceStarter</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java
similarity index 67%
copy from at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
copy to at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java
index 6b44c46e..a61feffe 100644
--- a/at-sample/spring-seata/src/main/java/org/apache/seata/BusinessServiceTester.java
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/DubboStorageServiceStarter.java
@@ -14,24 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.seata;
+package org.apache.seata.storage;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.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 {
+@EnableDubbo
+@ComponentScan(basePackages = {"org.apache.seata.storage"})
+public class DubboStorageServiceStarter {
/**
* Enable PropertySource placeHolder
@@ -41,14 +37,8 @@ public class BusinessServiceTester {
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();
+ 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/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/DataSourceConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/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/spring-dubbo-seata-storage/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/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java
new file mode 100644
index 00000000..52923939
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/DubboConfiguration.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import static org.apache.seata.e2e.E2EUtil.isInE2ETest;
+
+/**
+ * @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();
+ if (isInE2ETest()) {
+ registryConfig.setAddress("zookeeper://zookeeper:2181");
+ } else {
+ 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/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/SeataConfiguration.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/config/SeataConfiguration.java
new file mode 100644
index 00000000..b5297677
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/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 org.apache.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/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/service/impl/StorageServiceImpl.java b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/java/org/apache/seata/storage/service/impl/StorageServiceImpl.java
new file mode 100644
index 00000000..b5678ca2
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/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 org.apache.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 = ?",
+ 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/spring-dubbo-seata-storage/src/main/resources/all.sql b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/all.sql
new file mode 100644
index 00000000..a6974d7f
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/application.properties
new file mode 100644
index 00000000..6fcc8f60
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/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://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.account.username=${mysql.user:root}
+spring.datasource.account.password=${mysql.password:123456}
+spring.datasource.account.driverClassName=com.mysql.cj.jdbc.Driver
+# stock db config
+spring.datasource.stock.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.stock.username=${mysql.user:root}
+spring.datasource.stock.password=${mysql.password:123456}
+spring.datasource.stock.driverClassName=com.mysql.cj.jdbc.Driver
+# order db config
+spring.datasource.order.url=jdbc:mysql://${mysql.address:127.0.0.1}:3306/seata?useSSL=false&serverTimezone=UTC
+spring.datasource.order.username=${mysql.user:root}
+spring.datasource.order.password=${mysql.password:123456}
+spring.datasource.order.driverClassName=com.mysql.cj.jdbc.Driver
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/file.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/file.conf
new file mode 100644
index 00000000..e426f666
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/logback.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/logback.xml
new file mode 100644
index 00000000..14ecfc13
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE" />
+ </root>
+
+</configuration>
diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/registry.conf b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/src/main/resources/registry.conf
new file mode 100644
index 00000000..a105dc3e
--- /dev/null
+++ b/at-sample/spring-dubbo-seata/spring-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/spring-dubbo-seata/src/main/resources/application.properties b/at-sample/spring-dubbo-seata/src/main/resources/application.properties
index 6970a07a..2e972bf6 100644
--- a/at-sample/spring-dubbo-seata/src/main/resources/application.properties
+++ b/at-sample/spring-dubbo-seata/src/main/resources/application.properties
@@ -3,16 +3,16 @@ 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=
-spring.datasource.account.password=
+spring.datasource.account.username=root
+spring.datasource.account.password=123456
spring.datasource.account.driverClassName=com.mysql.cj.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=
-spring.datasource.stock.password=
+spring.datasource.stock.username=root
+spring.datasource.stock.password=123456
spring.datasource.stock.driverClassName=com.mysql.cj.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=
-spring.datasource.order.password=
+spring.datasource.order.username=root
+spring.datasource.order.password=123456
spring.datasource.order.driverClassName=com.mysql.cj.jdbc.Driver
diff --git a/at-sample/spring-seata/e2e-files/sqlsh/all.sql b/at-sample/spring-seata/e2e-files/sqlsh/all.sql
new file mode 100644
index 00000000..07bce111
--- /dev/null
+++ b/at-sample/spring-seata/e2e-files/sqlsh/all.sql
@@ -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.
+--
+
+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`);
+
+insert into account_tbl (user_id, money) values ('U100001', 10000);
+insert into stock_tbl (commodity_code, count) values ('C00321', 100);
\ No newline at end of file
diff --git a/at-sample/spring-seata/e2e-files/success.yaml b/at-sample/spring-seata/e2e-files/success.yaml
new file mode 100644
index 00000000..946b0e70
--- /dev/null
+++ b/at-sample/spring-seata/e2e-files/success.yaml
@@ -0,0 +1 @@
+{"res": "success"}
\ No newline at end of file
diff --git a/at-sample/spring-seata/e2e-replace/application.properties b/at-sample/spring-seata/e2e-replace/application.properties
new file mode 100644
index 00000000..d83ddefd
--- /dev/null
+++ b/at-sample/spring-seata/e2e-replace/application.properties
@@ -0,0 +1,5 @@
+spring.application.name=spring-seata
+spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://mysqlAddress:3306/seata?useSSL=false&useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=user
+spring.datasource.password=123456
\ No newline at end of file
diff --git a/at-sample/spring-seata/e2e-replace/file.conf b/at-sample/spring-seata/e2e-replace/file.conf
new file mode 100644
index 00000000..cf823052
--- /dev/null
+++ b/at-sample/spring-seata/e2e-replace/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 = "seata: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/pom.xml b/at-sample/spring-seata/pom.xml
index f3b741ee..025a3bc8 100644
--- a/at-sample/spring-seata/pom.xml
+++ b/at-sample/spring-seata/pom.xml
@@ -83,4 +83,30 @@
<version>8.0.28</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.2.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.seata.BusinessServiceTester</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/at-sample/at-api/seata-e2e.yaml b/at-sample/spring-seata/seata-e2e.yaml
similarity index 83%
copy from at-sample/at-api/seata-e2e.yaml
copy to at-sample/spring-seata/seata-e2e.yaml
index 3e7f833d..6b837955 100644
--- a/at-sample/at-api/seata-e2e.yaml
+++ b/at-sample/spring-seata/seata-e2e.yaml
@@ -1,5 +1,5 @@
e2e:
- scene_name: at-api
+ scene_name: at-spring-seata
# retry config
retry:
max: 5
@@ -9,9 +9,9 @@ e2e:
modules:
# provider service
providers:
- - name: at-api
+ - name: spring-seata
docker_service:
- hostname: at-api
+ hostname: spring-seata
restart: on-failure
container_name: test
depends_on:
@@ -46,13 +46,13 @@ e2e:
SEATA_PORT: 8091
STORE_MODE: file
replace:
- - source: e2e-replace/jdbc.properties
- dest: src/main/resources/jdbc.properties
+ - source: e2e-replace/application.properties
+ dest: src/main/resources/application.properties
- source: e2e-replace/file.conf
dest: src/main/resources/file.conf
# cases to verify
cases:
- - name: normal test rollback
+ - name: normal test success
invoke: 'docker exec test cat result.yaml'
- verify: './e2e-files/rollback.yaml'
\ No newline at end of file
+ verify: './e2e-files/success.yaml'
\ 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
index 6b44c46e..dad00743 100644
--- 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
@@ -16,8 +16,9 @@
*/
package org.apache.seata;
-import org.apache.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
+import org.apache.seata.e2e.E2EUtil;
import org.apache.seata.service.BusinessService;
+import org.apache.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -46,9 +47,20 @@ public class BusinessServiceTester {
BusinessService businessService = annotationConfigApplicationContext.getBean(BusinessService.class);
- Thread thread = new Thread(() -> businessService.purchase("U100001", "C00321", 2));
+ Thread thread = new Thread(() -> {
+ String res = "{\"res\": \"success\"}";
+ try {
+ businessService.purchase("U100001", "C00321", 2);
+ if (E2EUtil.isInE2ETest()) {
+ E2EUtil.writeE2EResFile(res);
+ }
+ } catch (Exception e) {
+ if (E2EUtil.isInE2ETest() && "random exception mock!".equals(e.getMessage())) {
+ E2EUtil.writeE2EResFile(res);
+ }
+ }
+ });
thread.start();
- thread.join();
//keep run
Thread.currentThread().join();
diff --git a/at-sample/spring-seata/src/main/java/org/apache/seata/e2e/E2EUtil.java b/at-sample/spring-seata/src/main/java/org/apache/seata/e2e/E2EUtil.java
new file mode 100644
index 00000000..80c76bc4
--- /dev/null
+++ b/at-sample/spring-seata/src/main/java/org/apache/seata/e2e/E2EUtil.java
@@ -0,0 +1,25 @@
+package org.apache.seata.e2e;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+
+/**
+ * @author jingliu_xiong@foxmail.com
+ */
+public class E2EUtil {
+ public static void writeE2EResFile(String outPutRes) {
+ try {
+ Files.write(Paths.get("result.yaml"), outPutRes.getBytes());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static boolean isInE2ETest() {
+ Map<String, String> envs = System.getenv();
+ String env = envs.getOrDefault("E2E_ENV", "");
+ return "open".equals(env);
+ }
+}
diff --git a/at-sample/springboot-dubbo-seata/seata-e2e.yaml b/at-sample/springboot-dubbo-seata/seata-e2e.yaml
index bf3f2510..c8381cbb 100644
--- a/at-sample/springboot-dubbo-seata/seata-e2e.yaml
+++ b/at-sample/springboot-dubbo-seata/seata-e2e.yaml
@@ -3,7 +3,7 @@ e2e:
# retry config
retry:
max: 5
- interval: 10s
+ interval: 20s
total_timeout: 20m
# services in docker-compose
modules:
@@ -104,7 +104,7 @@ e2e:
- name: zookeeper
docker_service:
hostname: zookeeper
- image: zookeeper:3.5.7
+ image: zookeeper:3.8.4
# ports:
# - "2181:2181"
healthcheck:
diff --git a/e2e-test/e2e-test-builder/src/main/java/org/apache/seata/builder/ImageBuilder.java b/e2e-test/e2e-test-builder/src/main/java/org/apache/seata/builder/ImageBuilder.java
index 53629593..f26c0655 100644
--- a/e2e-test/e2e-test-builder/src/main/java/org/apache/seata/builder/ImageBuilder.java
+++ b/e2e-test/e2e-test-builder/src/main/java/org/apache/seata/builder/ImageBuilder.java
@@ -38,6 +38,8 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.apache.seata.util.LogUtils.printProcessLog;
+
/**
* @author jingliu_xiong@foxmail.com
*/
@@ -92,7 +94,6 @@ public class ImageBuilder {
private int packageMavenParentModule(File moduleDir) throws IOException, InterruptedException {
LOGGER.info("Packaging Maven module: " + moduleDir.getPath());
ProcessBuilder builder = new ProcessBuilder();
- builder.inheritIO();
builder.directory(moduleDir);
// builder.command("mvn.cmd", "clean", "package");
if (System.getProperty("os.name").contains("Windows")) {
@@ -101,6 +102,7 @@ public class ImageBuilder {
builder.command("mvn", "clean", "package");
}
Process process = builder.start();
+ printProcessLog(LOGGER, process);
int exitCode = process.waitFor();
LOGGER.info(String.format("Maven module %s packaging finished with exit code %d", moduleDir, exitCode));
return exitCode;
@@ -146,10 +148,10 @@ public class ImageBuilder {
String moduleComposeDir = new File(composeDir, e2EConfig.getScene_name() + "-"
+ module.getName()).getAbsolutePath();
ProcessBuilder builder = new ProcessBuilder();
- builder.inheritIO();
builder.directory(new File(moduleComposeDir));
builder.command("docker", "build", "-t", String.format("%s:%s", module.getName(), "0.0.1"), ".");
Process process = builder.start();
+ printProcessLog(LOGGER, process);
int exitCode = process.waitFor();
if (exitCode != 0) {
LOGGER.warn(String.format("Docker image for module %s build failed with exit code %d", module.getName(), exitCode));
diff --git a/e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java b/e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java
index bf6f929d..22c104fa 100644
--- a/e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java
+++ b/e2e-test/e2e-test-runner/src/main/java/org/apache/seata/controller/SkyWalkingController.java
@@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
+import static org.apache.seata.util.LogUtils.printProcessLog;
+
/**
* @author jingliu_xiong@foxmail.com
*/
@@ -43,10 +45,10 @@ public class SkyWalkingController {
LOGGER.info("Running Seate e2e test by SkyWalking-E2E: " + file.getName());
try {
ProcessBuilder builder = new ProcessBuilder();
- builder.inheritIO();
builder.directory(file);
builder.command("e2e", "run");
Process process = builder.start();
+ printProcessLog(LOGGER, process);
int exitCode = process.waitFor();
if (exitCode != 0) {
LOGGER.warn(String.format(" Seate e2e test %s by SkyWalking-E2E fail with exit code %d",
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org