This is an automated email from the ASF dual-hosted git repository. jianbin 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 ca73bd92 add SagaAnnotation sample (#712) ca73bd92 is described below commit ca73bd928b21af4e0e78ba4cbe45b6ec83a30831 Author: funkye <jian...@apache.org> AuthorDate: Sat Jun 28 21:01:24 2025 +0800 add SagaAnnotation sample (#712) --- at-sample/at-api/pom.xml | 4 +- at-sample/at-api/seata-e2e.yaml | 2 +- at-sample/dubbo-samples-seata/pom.xml | 2 +- at-sample/dubbo-samples-seata/seata-e2e.yaml | 2 +- at-sample/spring-dubbo-seata/pom.xml | 2 +- at-sample/spring-dubbo-seata/seata-e2e.yaml | 2 +- .../spring-dubbo-seata-account/pom.xml | 8 +- .../spring-dubbo-seata-business/pom.xml | 8 +- .../spring-dubbo-seata-common/pom.xml | 4 +- .../spring-dubbo-seata-order/pom.xml | 8 +- .../spring-dubbo-seata-storage/pom.xml | 8 +- at-sample/spring-seata/pom.xml | 9 +- at-sample/spring-seata/seata-e2e.yaml | 2 +- at-sample/springboot-dubbo-seata/pom.xml | 2 +- at-sample/springboot-dubbo-seata/seata-e2e.yaml | 2 +- .../springboot-dubbo-seata-account/pom.xml | 8 +- .../springboot-dubbo-seata-business/pom.xml | 8 +- .../springboot-dubbo-seata-common/pom.xml | 4 +- .../springboot-dubbo-seata-order/pom.xml | 8 +- .../springboot-dubbo-seata-storage/pom.xml | 8 +- at-sample/springboot-mybatis-seata/pom.xml | 4 +- at-sample/springboot-mybatis-seata/seata-e2e.yaml | 2 +- at-sample/springboot-seata/pom.xml | 4 +- at-sample/springboot-seata/seata-e2e.yaml | 2 +- e2e-test/e2e-test-builder/pom.xml | 4 +- e2e-test/e2e-test-runner/pom.xml | 6 +- e2e-test/pom.xml | 2 +- pom.xml | 5 +- saga-annotation-sample/e2e-files/rollback.yaml | 19 ++++ saga-annotation-sample/e2e-replace/file.conf | 126 +++++++++++++++++++++ .../pom.xml | 34 +++--- .../seata-e2e.yaml | 26 ++--- .../src/main/java/org/apache/seata/Main.java | 59 ++++++++++ .../java/org/apache/seata/action/ResultHolder.java | 52 +++++++++ .../org/apache/seata/action/SagaActionOne.java | 39 +++++++ .../org/apache/seata/action/SagaActionTwo.java | 44 +++++++ .../seata/action/impl/SagaActionOneImpl.java | 47 ++++++++ .../seata/action/impl/SagaActionTwoImpl.java | 60 ++++++++++ .../seata/service/SagaTransactionService.java | 82 ++++++++++++++ .../src/main/resources/application.yml | 33 ++++++ saga-sample/spring-seata-dubbo-saga/pom.xml | 2 +- saga-sample/spring-seata-dubbo-saga/seata-e2e.yaml | 2 +- .../spring-seata-dubbo-saga-common/pom.xml | 4 +- .../spring-seata-dubbo-saga-consumer/pom.xml | 8 +- .../spring-seata-dubbo-saga-provider/pom.xml | 8 +- saga-sample/spring-seata-saga/pom.xml | 4 +- saga-sample/spring-seata-saga/seata-e2e.yaml | 2 +- tcc-sample/spring-dubbo-seata-tcc/pom.xml | 2 +- tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml | 2 +- .../spring-dubbo-seata-tcc-consumer/pom.xml | 6 +- .../spring-dubbo-seata-tcc-provider/pom.xml | 6 +- tcc-sample/springboot-sofarpc-seata-tcc/pom.xml | 4 +- .../springboot-sofarpc-seata-tcc/seata-e2e.yaml | 2 +- xa-sample/springboot-feign-seata-xa/pom.xml | 2 +- xa-sample/springboot-feign-seata-xa/seata-e2e.yaml | 2 +- .../springboot-feign-seata-account/pom.xml | 6 +- .../springboot-feign-seata-business/pom.xml | 6 +- .../springboot-feign-seata-order/pom.xml | 6 +- .../springboot-feign-seata-storage/pom.xml | 6 +- 59 files changed, 700 insertions(+), 131 deletions(-) diff --git a/at-sample/at-api/pom.xml b/at-sample/at-api/pom.xml index 6d57f43f..0a5020f5 100644 --- a/at-sample/at-api/pom.xml +++ b/at-sample/at-api/pom.xml @@ -21,7 +21,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.seata</groupId> <artifactId>at-api</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -59,7 +59,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/at-sample/at-api/seata-e2e.yaml b/at-sample/at-api/seata-e2e.yaml index 1812cd20..a16b0a4c 100644 --- a/at-sample/at-api/seata-e2e.yaml +++ b/at-sample/at-api/seata-e2e.yaml @@ -59,7 +59,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/at-sample/dubbo-samples-seata/pom.xml b/at-sample/dubbo-samples-seata/pom.xml index a39a8a4b..3a5ed806 100644 --- a/at-sample/dubbo-samples-seata/pom.xml +++ b/at-sample/dubbo-samples-seata/pom.xml @@ -85,7 +85,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> </dependencyManagement> diff --git a/at-sample/dubbo-samples-seata/seata-e2e.yaml b/at-sample/dubbo-samples-seata/seata-e2e.yaml index 417b7faf..9030f842 100644 --- a/at-sample/dubbo-samples-seata/seata-e2e.yaml +++ b/at-sample/dubbo-samples-seata/seata-e2e.yaml @@ -102,7 +102,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/at-sample/spring-dubbo-seata/pom.xml b/at-sample/spring-dubbo-seata/pom.xml index 5c63f2ea..e44f623c 100644 --- a/at-sample/spring-dubbo-seata/pom.xml +++ b/at-sample/spring-dubbo-seata/pom.xml @@ -22,7 +22,7 @@ <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata</name> <description>spring-dubbo-seata</description> <packaging>pom</packaging> diff --git a/at-sample/spring-dubbo-seata/seata-e2e.yaml b/at-sample/spring-dubbo-seata/seata-e2e.yaml index 98c022ae..21dbcf77 100644 --- a/at-sample/spring-dubbo-seata/seata-e2e.yaml +++ b/at-sample/spring-dubbo-seata/seata-e2e.yaml @@ -116,7 +116,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml index ce7d73b9..8ae7d756 100644 --- a/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml +++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-account/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-account</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-account</name> <description>spring-dubbo-seata-account</description> @@ -64,7 +64,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -105,7 +105,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml index 0536f778..0e0958d8 100644 --- a/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml +++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-business/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-business</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-business</name> <description>spring-dubbo-seata-business</description> @@ -64,7 +64,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -106,7 +106,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> 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 index 8cca723f..d4c11545 100644 --- a/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/pom.xml +++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-common/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-common</name> <description>spring-dubbo-seata-common</description> diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml index cb1d8b66..c6de17bb 100644 --- a/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml +++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-order/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-order</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-order</name> <description>spring-dubbo-seata-order</description> @@ -64,7 +64,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -105,7 +105,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml index 1827db6f..0406e107 100644 --- a/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml +++ b/at-sample/spring-dubbo-seata/spring-dubbo-seata-storage/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-storage</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-storage</name> <description>spring-dubbo-seata-storage</description> @@ -64,7 +64,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -105,7 +105,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/spring-seata/pom.xml b/at-sample/spring-seata/pom.xml index f7b7a6b4..ddbc3b51 100644 --- a/at-sample/spring-seata/pom.xml +++ b/at-sample/spring-seata/pom.xml @@ -22,7 +22,7 @@ <groupId>org.apache.seata</groupId> <artifactId>spring-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -32,6 +32,11 @@ </properties> <dependencies> + <dependency> + <groupId>javax.annotation</groupId> + <artifactId>javax.annotation-api</artifactId> + <version>1.3.2</version> + </dependency> <!-- log dependency start --> <dependency> <groupId>org.slf4j</groupId> @@ -60,7 +65,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/at-sample/spring-seata/seata-e2e.yaml b/at-sample/spring-seata/seata-e2e.yaml index e85a9bd4..189bdc64 100644 --- a/at-sample/spring-seata/seata-e2e.yaml +++ b/at-sample/spring-seata/seata-e2e.yaml @@ -59,7 +59,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/at-sample/springboot-dubbo-seata/pom.xml b/at-sample/springboot-dubbo-seata/pom.xml index 6058c0ee..98baa9b4 100644 --- a/at-sample/springboot-dubbo-seata/pom.xml +++ b/at-sample/springboot-dubbo-seata/pom.xml @@ -26,7 +26,7 @@ </parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata</name> <description>springboot-dubbo-seata</description> <packaging>pom</packaging> diff --git a/at-sample/springboot-dubbo-seata/seata-e2e.yaml b/at-sample/springboot-dubbo-seata/seata-e2e.yaml index 0d5debfb..bd832b03 100644 --- a/at-sample/springboot-dubbo-seata/seata-e2e.yaml +++ b/at-sample/springboot-dubbo-seata/seata-e2e.yaml @@ -112,7 +112,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml index 3b1a57ce..4c3b0e33 100644 --- a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml +++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-account/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-dubbo-seata-account</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata-account</name> <description>springboot-dubbo-seata-account</description> @@ -66,7 +66,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -105,7 +105,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml index cadafa9f..88193b80 100644 --- a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml +++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-business/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-dubbo-seata-business</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata-business</name> <description>springboot-dubbo-seata-business</description> @@ -66,7 +66,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -93,7 +93,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml index 8d8a036b..d021ae9b 100644 --- a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml +++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-common/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata-common</name> <description>springboot-dubbo-seata-common</description> <packaging>jar</packaging> diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml index 996a3ebc..67b91cda 100644 --- a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml +++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-order/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-dubbo-seata-order</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata-order</name> <description>springboot-dubbo-seata-order</description> @@ -66,7 +66,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -105,7 +105,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml index 1a5f9b15..da24200e 100644 --- a/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml +++ b/at-sample/springboot-dubbo-seata/springboot-dubbo-seata-storage/pom.xml @@ -22,10 +22,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-dubbo-seata-storage</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-dubbo-seata-storage</name> <description>springboot-dubbo-seata-storage</description> @@ -67,7 +67,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -106,7 +106,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>springboot-dubbo-seata-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/at-sample/springboot-mybatis-seata/pom.xml b/at-sample/springboot-mybatis-seata/pom.xml index fbf45076..5cc80201 100644 --- a/at-sample/springboot-mybatis-seata/pom.xml +++ b/at-sample/springboot-mybatis-seata/pom.xml @@ -26,7 +26,7 @@ </parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-mybatis-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-mybatis-seata</name> <description>springboot-mybatis-seata</description> <properties> @@ -47,7 +47,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/at-sample/springboot-mybatis-seata/seata-e2e.yaml b/at-sample/springboot-mybatis-seata/seata-e2e.yaml index 5ad40a54..cbcb28cf 100644 --- a/at-sample/springboot-mybatis-seata/seata-e2e.yaml +++ b/at-sample/springboot-mybatis-seata/seata-e2e.yaml @@ -59,7 +59,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/at-sample/springboot-seata/pom.xml b/at-sample/springboot-seata/pom.xml index 79a5be8d..a92bda60 100644 --- a/at-sample/springboot-seata/pom.xml +++ b/at-sample/springboot-seata/pom.xml @@ -26,7 +26,7 @@ </parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-seata</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-seata</name> <description>springboot-seata</description> <properties> @@ -47,7 +47,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/at-sample/springboot-seata/seata-e2e.yaml b/at-sample/springboot-seata/seata-e2e.yaml index 08440368..66b092a6 100644 --- a/at-sample/springboot-seata/seata-e2e.yaml +++ b/at-sample/springboot-seata/seata-e2e.yaml @@ -59,7 +59,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/e2e-test/e2e-test-builder/pom.xml b/e2e-test/e2e-test-builder/pom.xml index 2958989a..081e7787 100644 --- a/e2e-test/e2e-test-builder/pom.xml +++ b/e2e-test/e2e-test-builder/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>e2e-test</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <groupId>org.apache.seata</groupId> <artifactId>e2e-test-builder</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>e2e-test-builder</name> <dependencies> diff --git a/e2e-test/e2e-test-runner/pom.xml b/e2e-test/e2e-test-runner/pom.xml index f3281a86..54ad8b00 100644 --- a/e2e-test/e2e-test-runner/pom.xml +++ b/e2e-test/e2e-test-runner/pom.xml @@ -21,18 +21,18 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>e2e-test</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <groupId>org.apache.seata</groupId> <artifactId>e2e-test-runner</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>e2e-test-runner</name> <dependencies> <dependency> <groupId>org.apache.seata</groupId> <artifactId>e2e-test-builder</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index 456552aa..13643e9f 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -20,7 +20,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.seata</groupId> <artifactId>e2e-test</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <packaging>pom</packaging> <name>e2e-test</name> <modules> diff --git a/pom.xml b/pom.xml index f84afe49..8afb6ddc 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,10 @@ <groupId>org.apache.seata</groupId> <artifactId>seata-samples</artifactId> <packaging>pom</packaging> - <version>2.1.0</version> + <modules> + <module>saga-annotation-sample</module> + </modules> + <version>2.3.0</version> <name>seata-samples ${project.version}</name> </project> diff --git a/saga-annotation-sample/e2e-files/rollback.yaml b/saga-annotation-sample/e2e-files/rollback.yaml new file mode 100644 index 00000000..0d5ae93a --- /dev/null +++ b/saga-annotation-sample/e2e-files/rollback.yaml @@ -0,0 +1,19 @@ +# +# 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. +# + +{"res": "rollback"} \ No newline at end of file diff --git a/saga-annotation-sample/e2e-replace/file.conf b/saga-annotation-sample/e2e-replace/file.conf new file mode 100644 index 00000000..cf823052 --- /dev/null +++ b/saga-annotation-sample/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/saga-sample/spring-seata-dubbo-saga/pom.xml b/saga-annotation-sample/pom.xml similarity index 62% copy from saga-sample/spring-seata-dubbo-saga/pom.xml copy to saga-annotation-sample/pom.xml index 0f72db2d..3f2a52ee 100644 --- a/saga-sample/spring-seata-dubbo-saga/pom.xml +++ b/saga-annotation-sample/pom.xml @@ -19,24 +19,32 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.seata</groupId> + <artifactId>seata-samples</artifactId> + <version>2.3.0</version> + </parent> - <groupId>org.apache.seata</groupId> - <artifactId>spring-seata-dubbo-saga</artifactId> - <version>2.1.0</version> - <packaging>pom</packaging> - - <modules> - <module>spring-seata-dubbo-saga-consumer</module> - <module>spring-seata-dubbo-saga-provider</module> - <module>spring-seata-dubbo-saga-common</module> - </modules> + <artifactId>saga-annotation-sample</artifactId> <properties> + <maven.compiler.source>8</maven.compiler.source> + <maven.compiler.target>8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> </properties> + <dependencies> + <dependency> + <groupId>org.apache.seata</groupId> + <artifactId>seata-spring-boot-starter</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + <version>2.7.18</version> + </dependency> + </dependencies> + </project> \ No newline at end of file diff --git a/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml b/saga-annotation-sample/seata-e2e.yaml similarity index 68% copy from tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml copy to saga-annotation-sample/seata-e2e.yaml index be899a5d..a1c16a1e 100644 --- a/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml +++ b/saga-annotation-sample/seata-e2e.yaml @@ -17,7 +17,7 @@ # e2e: - scene_name: tcc-springboot-sofarpc-seata-tcc + scene_name: at-api # retry config retry: max: 5 @@ -25,24 +25,19 @@ e2e: total_timeout: 10m # services in docker-compose modules: - # consumer service - consumers: - - name: springboot-sofarpc-seata-tcc + # provider service + providers: + - name: saga-annotation-sample docker_service: - hostname: springboot-sofarpc-seata-tcc + hostname: saga-annotation-sample restart: on-failure container_name: test - depends_on: - seata-server: - condition: service_started environment: E2E_ENV: open - # infrastructure services - infrastructures: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file @@ -52,9 +47,6 @@ e2e: # cases to verify cases: - - name: normal test rollback - invoke: 'docker exec test cat rollback.yaml' - verify: './e2e-files/rollback.yaml' - - name: normal test commit - invoke: 'docker exec test cat commit.yaml' - 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/rollback.yaml' \ No newline at end of file diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/Main.java b/saga-annotation-sample/src/main/java/org/apache/seata/Main.java new file mode 100644 index 00000000..6f10fa53 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/Main.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seata; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.apache.seata.action.ResultHolder; +import org.apache.seata.core.exception.TransactionException; +import org.apache.seata.service.SagaTransactionService; +import org.apache.seata.tm.api.GlobalTransaction; +import org.apache.seata.tm.api.GlobalTransactionContext; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; + +@SpringBootApplication(scanBasePackages = { "org.apache.seata"}) +public class Main { + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException, TimeoutException, TransactionException { + boolean isInE2ETest = isInE2ETest(); + ConfigurableApplicationContext context = SpringApplication.run(Main.class, args); + SagaTransactionService sagaTransactionService = context.getBean(SagaTransactionService.class); + String xid = sagaTransactionService.doTransactionCommit(); + ResultHolder.getActionTwoResult(xid).get(10, TimeUnit.SECONDS); + GlobalTransaction globalTransaction = GlobalTransactionContext.createNew(); + globalTransaction.begin(); + xid = globalTransaction.getXid(); + try { + sagaTransactionService.doTransactionRollback(); + } catch (Exception e) { + globalTransaction.rollback(); + } + ResultHolder.getActionTwoResult(xid).get(10, TimeUnit.SECONDS); + } + + public static boolean isInE2ETest() { + Map<String, String> envs = System.getenv(); + String env = envs.getOrDefault("E2E_ENV", ""); + return "open".equals(env); + } + +} \ No newline at end of file diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/action/ResultHolder.java b/saga-annotation-sample/src/main/java/org/apache/seata/action/ResultHolder.java new file mode 100644 index 00000000..592d26f2 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/action/ResultHolder.java @@ -0,0 +1,52 @@ +/* + * 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.action; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; + +/** + * The type Result holder. + * + */ +public class ResultHolder { + + private static final Map<String, CompletableFuture<Void>> actionTwoResults = new ConcurrentHashMap<>(); + + + /** + * Set action two result. + * + * @param txId the tx id + * @param completableFuture the completableFuture + */ + public static void setActionTwoResult(String txId, CompletableFuture<Void> completableFuture) { + actionTwoResults.put(txId, completableFuture); + } + + /** + * Get action two result string. + * + * @param txId the tx id + * @return the string + */ + public static CompletableFuture<Void> getActionTwoResult(String txId) { + return actionTwoResults.get(txId); + } + +} diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java new file mode 100644 index 00000000..9c882a55 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionOne.java @@ -0,0 +1,39 @@ +/* + * 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.action; + +import org.apache.seata.rm.tcc.api.BusinessActionContext; + +public interface SagaActionOne { + + /** + * commit boolean. + * + * @param actionContext the action context + * @param a the a + * @return the boolean + */ + boolean commit(BusinessActionContext actionContext, int a); + + /** + * Rollback boolean. + * + * @param actionContext the action context + * @return the boolean + */ + boolean rollback(BusinessActionContext actionContext); +} diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java new file mode 100644 index 00000000..a75ce259 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/action/SagaActionTwo.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seata.action; + +import java.util.List; + +import org.apache.seata.rm.tcc.api.BusinessActionContext; + +public interface SagaActionTwo { + + /** + * commit boolean. + * + * @param actionContext the action context + * @param b the b + * @param list the list + * @return the boolean + */ + boolean commit(BusinessActionContext actionContext, String b, List list); + + + /** + * Rollback boolean. + * + * @param actionContext the action context + * @return the boolean + */ + public boolean rollback(BusinessActionContext actionContext); + +} \ No newline at end of file diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java new file mode 100644 index 00000000..b150ef22 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionOneImpl.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seata.action.impl; + +import org.apache.seata.action.SagaActionOne; +import org.apache.seata.rm.tcc.api.BusinessActionContext; +import org.apache.seata.rm.tcc.api.BusinessActionContextParameter; +import org.apache.seata.rm.tcc.api.LocalTCC; +import org.apache.seata.saga.rm.api.CompensationBusinessAction; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +@Service +@LocalTCC +public class SagaActionOneImpl implements SagaActionOne { + + @Override + @CompensationBusinessAction(name = "DubboSagaActionOne", compensationMethod = "rollback") + public boolean commit(BusinessActionContext actionContext,@BusinessActionContextParameter(paramName = "a") int a) { + String xid = actionContext.getXid(); + System.out.println("TccActionOne prepare, xid:" + xid + ", a:" + a); + return true; + } + + @Override + public boolean rollback(BusinessActionContext actionContext) { + String xid = actionContext.getXid(); + Object a = actionContext.getActionContext("a"); + Assert.notNull(a); + System.out.println("TccActionOne prepare, xid:" + xid + ", a:" + a); + return true; + } +} diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.java b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.java new file mode 100644 index 00000000..c500a634 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/action/impl/SagaActionTwoImpl.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.action.impl; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +import org.apache.seata.action.ResultHolder; +import org.apache.seata.action.SagaActionTwo; +import org.apache.seata.rm.tcc.api.BusinessActionContext; +import org.apache.seata.rm.tcc.api.BusinessActionContextParameter; +import org.apache.seata.rm.tcc.api.LocalTCC; +import org.apache.seata.saga.rm.api.CompensationBusinessAction; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +@Service +@LocalTCC +public class SagaActionTwoImpl implements SagaActionTwo { + + @Override + @CompensationBusinessAction(name = "DubboTccActionTwo", compensationMethod = "rollback") + public boolean commit(BusinessActionContext actionContext, @BusinessActionContextParameter(paramName = "b") String b, + @BusinessActionContextParameter(paramName = "c", index = 1) List list) { + String xid = actionContext.getXid(); + System.out.println("TccActionTwo prepare, xid:" + xid + ", b:" + b + ", c:" + list.get(1)); + CompletableFuture<Void> completableFuture = new CompletableFuture<>(); + ResultHolder.setActionTwoResult(xid,completableFuture); + completableFuture.complete(null); + return true; + } + + @Override + public boolean rollback(BusinessActionContext actionContext) { + String xid = actionContext.getXid(); + Assert.isTrue(actionContext.getActionContext("b") != null); + Assert.isTrue(actionContext.getActionContext("c") != null); + System.out.println( + "TccActionTwo rollback, xid:" + xid + ", b:" + actionContext.getActionContext("b") + ", c:" + actionContext + .getActionContext("c")); + CompletableFuture<Void> completableFuture = ResultHolder.getActionTwoResult(xid); + completableFuture.complete(null); + return true; + } + +} diff --git a/saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java b/saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java new file mode 100644 index 00000000..a9744249 --- /dev/null +++ b/saga-annotation-sample/src/main/java/org/apache/seata/service/SagaTransactionService.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seata.service; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Resource; +import org.apache.seata.action.SagaActionOne; +import org.apache.seata.action.SagaActionTwo; +import org.apache.seata.core.context.RootContext; +import org.apache.seata.spring.annotation.GlobalTransactional; +import org.springframework.stereotype.Component; + +/** + * The type Saga transaction service. + */ +@Component +public class SagaTransactionService { + + @Resource + private SagaActionOne sagaActionOne; + + @Resource + private SagaActionTwo sagaActionTwo; + + /** + * 发起分布式事务 + * + * @return string string + */ + @GlobalTransactional + public String doTransactionCommit() { + //第一个TCC 事务参与者 + boolean result = sagaActionOne.commit(null, 1); + if (!result) { + throw new RuntimeException("TccActionOne failed."); + } + List<String> list = new ArrayList<>(); + list.add("c1"); + list.add("c2"); + result = sagaActionTwo.commit(null, "two", list); + if (!result) { + throw new RuntimeException("TccActionTwo failed."); + } + return RootContext.getXID(); + } + + /** + * Do transaction rollback string. + */ + @GlobalTransactional + public void doTransactionRollback() { + //第一个TCC 事务参与者 + boolean result = sagaActionOne.commit(null, 1); + if (!result) { + throw new RuntimeException("TccActionOne failed."); + } + List<String> list = new ArrayList<>(); + list.add("c1"); + list.add("c2"); + result = sagaActionTwo.commit(null, "two", list); + if (!result) { + throw new RuntimeException("TccActionTwo failed."); + } + throw new RuntimeException("transaction rollback"); + } + +} diff --git a/saga-annotation-sample/src/main/resources/application.yml b/saga-annotation-sample/src/main/resources/application.yml new file mode 100644 index 00000000..60f69aec --- /dev/null +++ b/saga-annotation-sample/src/main/resources/application.yml @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +seata: + enabled: true + application-id: applicationName + tx-service-group: default_tx_group + service: + vgroup-mapping: + default_tx_group: default + grouplist: + default: 127.0.0.1:8091 + disable-global-transaction: false + config: + type: file + registry: + type: file + file: + name: file.conf diff --git a/saga-sample/spring-seata-dubbo-saga/pom.xml b/saga-sample/spring-seata-dubbo-saga/pom.xml index 0f72db2d..6eecbcb1 100644 --- a/saga-sample/spring-seata-dubbo-saga/pom.xml +++ b/saga-sample/spring-seata-dubbo-saga/pom.xml @@ -22,7 +22,7 @@ <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <packaging>pom</packaging> <modules> diff --git a/saga-sample/spring-seata-dubbo-saga/seata-e2e.yaml b/saga-sample/spring-seata-dubbo-saga/seata-e2e.yaml index 400303ce..f599924d 100644 --- a/saga-sample/spring-seata-dubbo-saga/seata-e2e.yaml +++ b/saga-sample/spring-seata-dubbo-saga/seata-e2e.yaml @@ -63,7 +63,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-common/pom.xml b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-common/pom.xml index aa0fcbd7..a68da679 100644 --- a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-common/pom.xml +++ b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-common/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-seata-dubbo-saga-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-seata-dubbo-tcc-common</name> <description>spring-seata-dubbo-tcc-common</description> diff --git a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-consumer/pom.xml b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-consumer/pom.xml index d148792f..bdf1e2bc 100644 --- a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-consumer/pom.xml +++ b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-consumer/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-seata-dubbo-saga-consumer</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-seata-dubbo-tcc-consumer</name> <description>spring-seata-dubbo-tcc-consumer</description> @@ -62,7 +62,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -119,7 +119,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-provider/pom.xml b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-provider/pom.xml index 6a867a88..177189a9 100644 --- a/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-provider/pom.xml +++ b/saga-sample/spring-seata-dubbo-saga/spring-seata-dubbo-saga-provider/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-seata-dubbo-saga-provider</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-seata-dubbo-tcc-provider</name> <description>spring-seata-dubbo-tcc-provider</description> @@ -62,7 +62,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> @@ -119,7 +119,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>spring-seata-dubbo-saga-common</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> </dependencies> diff --git a/saga-sample/spring-seata-saga/pom.xml b/saga-sample/spring-seata-saga/pom.xml index 1d7c464c..aa3cf5bf 100644 --- a/saga-sample/spring-seata-saga/pom.xml +++ b/saga-sample/spring-seata-saga/pom.xml @@ -22,7 +22,7 @@ <groupId>org.apache.seata</groupId> <artifactId>spring-seata-saga</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -60,7 +60,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/saga-sample/spring-seata-saga/seata-e2e.yaml b/saga-sample/spring-seata-saga/seata-e2e.yaml index 8b47313b..296fbb8e 100644 --- a/saga-sample/spring-seata-saga/seata-e2e.yaml +++ b/saga-sample/spring-seata-saga/seata-e2e.yaml @@ -43,7 +43,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/tcc-sample/spring-dubbo-seata-tcc/pom.xml b/tcc-sample/spring-dubbo-seata-tcc/pom.xml index d2c30f6c..01ca2a37 100644 --- a/tcc-sample/spring-dubbo-seata-tcc/pom.xml +++ b/tcc-sample/spring-dubbo-seata-tcc/pom.xml @@ -21,7 +21,7 @@ <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-tcc</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <packaging>pom</packaging> <name>spring-dubbo-seata-tcc</name> diff --git a/tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml b/tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml index e9a3c163..028e6b8b 100644 --- a/tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml +++ b/tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml @@ -63,7 +63,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-consumer/pom.xml b/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-consumer/pom.xml index d19f275d..ebb8025b 100644 --- a/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-consumer/pom.xml +++ b/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-consumer/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-tcc</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-tcc-consumer</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-tcc-consumer</name> <description>spring-dubbo-seata-tcc-consumer</description> @@ -58,7 +58,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-provider/pom.xml b/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-provider/pom.xml index 4ccc76bd..cee1bab2 100644 --- a/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-provider/pom.xml +++ b/tcc-sample/spring-dubbo-seata-tcc/spring-dubbo-seata-tcc-provider/pom.xml @@ -21,11 +21,11 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>spring-dubbo-seata-tcc</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>spring-dubbo-seata-tcc-provider</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>spring-dubbo-seata-tcc-provider</name> <description>spring-dubbo-seata-tcc-provider</description> @@ -58,7 +58,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-all</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/tcc-sample/springboot-sofarpc-seata-tcc/pom.xml b/tcc-sample/springboot-sofarpc-seata-tcc/pom.xml index 24cd9ae3..ce5c72bd 100644 --- a/tcc-sample/springboot-sofarpc-seata-tcc/pom.xml +++ b/tcc-sample/springboot-sofarpc-seata-tcc/pom.xml @@ -26,7 +26,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.apache.seata</groupId> <artifactId>springboot-sofarpc-seata-tcc</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <packaging>jar</packaging> <name>spring-sofarpc-seata-tcc</name> @@ -54,7 +54,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml b/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml index be899a5d..e8346823 100644 --- a/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml +++ b/tcc-sample/springboot-sofarpc-seata-tcc/seata-e2e.yaml @@ -42,7 +42,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 environment: SEATA_PORT: 8091 STORE_MODE: file diff --git a/xa-sample/springboot-feign-seata-xa/pom.xml b/xa-sample/springboot-feign-seata-xa/pom.xml index f6612433..43523a4f 100644 --- a/xa-sample/springboot-feign-seata-xa/pom.xml +++ b/xa-sample/springboot-feign-seata-xa/pom.xml @@ -26,7 +26,7 @@ </parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-feign-seata-xa</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-feign-seata-xa</name> <description>springboot-feign-seata-xa</description> <packaging>pom</packaging> diff --git a/xa-sample/springboot-feign-seata-xa/seata-e2e.yaml b/xa-sample/springboot-feign-seata-xa/seata-e2e.yaml index 14601aa8..e82137d6 100644 --- a/xa-sample/springboot-feign-seata-xa/seata-e2e.yaml +++ b/xa-sample/springboot-feign-seata-xa/seata-e2e.yaml @@ -117,7 +117,7 @@ e2e: - name: seata-server docker_service: hostname: seata - image: apache/seata-server:2.1.0 + image: apache/seata-server:2.3.0 # ports: # - "7091:7091" # - "8091:8091" diff --git a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-account/pom.xml b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-account/pom.xml index d6a34fa8..9b540a04 100644 --- a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-account/pom.xml +++ b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-account/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-feign-seata-xa</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-feign-seata-account</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-feign-seata-account</name> <description>springboot-feign-seata-account</description> @@ -93,7 +93,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-business/pom.xml b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-business/pom.xml index 03306050..70704377 100644 --- a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-business/pom.xml +++ b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-business/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-feign-seata-xa</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-feign-seata-business</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-feign-seata-business</name> <description>springboot-feign-seata-business</description> @@ -88,7 +88,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-order/pom.xml b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-order/pom.xml index c3a53c55..3057bf3c 100644 --- a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-order/pom.xml +++ b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-order/pom.xml @@ -21,10 +21,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-feign-seata-xa</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-feign-seata-order</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-feign-seata-order</name> <description>springboot-feign-seata-order</description> @@ -88,7 +88,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> diff --git a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-storage/pom.xml b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-storage/pom.xml index 3e922ba9..1c8f5c80 100644 --- a/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-storage/pom.xml +++ b/xa-sample/springboot-feign-seata-xa/springboot-feign-seata-storage/pom.xml @@ -22,10 +22,10 @@ <parent> <groupId>org.apache.seata</groupId> <artifactId>springboot-feign-seata-xa</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </parent> <artifactId>springboot-feign-seata-storage</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> <name>springboot-feign-seata-storage</name> <description>springboot-feign-seata-storage</description> @@ -89,7 +89,7 @@ <dependency> <groupId>org.apache.seata</groupId> <artifactId>seata-spring-boot-starter</artifactId> - <version>2.1.0</version> + <version>2.3.0</version> </dependency> <dependency> --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org