fix: record verified Jackson module licenses
English | 简体中文
These examples show how Java applications start a distributed transaction and what happens when a participant fails. To see both outcomes in one run, start with the Spring Saga example below. To explore a particular transaction mode or framework, use the sample directory.
Apache Seata (incubating) is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. See DISCLAIMER.
The Spring Saga sample reduces inventory and then a balance. It uses an in-memory H2 database for the state machine and connects directly to a Seata Server. For this walkthrough, use Git, Bash, JDK 17, Maven 3.9 and Seata Server 2.3.0. The server version matches the client in the sample POM.
Start the transaction coordinator. Download and unpack apache-seata-2.3.0-incubating-bin.tar.gz from the Apache release archive. From the extracted distribution directory, run:
cd seata-server bash bin/seata-server.sh start -h 127.0.0.1 -p 8091 -m file
Wait for the server to listen on port 8091. The sample's file.conf maps my_test_tx_group to the default cluster at 127.0.0.1:8091.
Build and run the sample. In a second terminal, run:
git clone https://github.com/apache/incubator-seata-samples.git cd incubator-seata-samples mvn -f saga-sample/spring-seata-saga/pom.xml package java -jar saga-sample/spring-seata-saga/target/spring-seata-saga-2.3.0.jar
Check the outcome. Look for saga transaction commit succeed. twice, once for synchronous execution and once for asynchronous execution. The final run deliberately fails the balance step. The line saga transaction compensate succeed. confirms that compensation completed. Each message includes a transaction ID (XID).
To follow the code, open SagaTransactionStarter.java and find mockReduceBalanceFail. Follow the balance step's Catch transition to CompensationTrigger in the state machine definition. The action implementations contain the forward and compensating methods.
When finished, press Ctrl+C if the sample is still running. From the distribution's seata-server directory, run bash bin/seata-server.sh stop to stop the local coordinator.
| Directory | What to explore |
|---|---|
| at-sample/ | Automatic transaction (AT) examples using JDBC, Spring, Dubbo and MyBatis. BusinessService.java shows explicit begin, commit and rollback calls. The Dubbo walkthrough covers database setup for a multi-service example. |
| tcc-sample/ | Try, Confirm and Cancel operations. In the Spring/Dubbo example, start with the consumer that initiates the transaction, then follow the participant actions in the provider. A Spring Boot/SOFA RPC variant is also available. |
| saga-sample/ | JSON state machines and compensation. Compare the single-process Spring client above with the Dubbo consumer/provider version. |
| saga-annotation-sample/ | Annotation-based compensation. Follow SagaTransactionService into the annotated actions. |
| xa-sample/ | XA transactions across Spring Boot services using Feign. The business service initiates the purchase across the storage, order and account services. |
| e2e-test/ | The builder prepares container images and test definitions, and the runner executes scenarios described by each participating sample's seata-e2e.yaml. See the English or Chinese guide. |
The CI workflows build the examples and run E2E checks. The copyright template is used for source headers.
saga-annotation-sample. For the other projects, import the chosen sample‘s POM into your IDE or pass its path to Maven with -f. Check that POM for the project’s Seata and framework versions.springboot-dubbo-seata), and declare its dependencies in its own Maven project. See the contribution guide and the Seata transaction walkthrough.For dependency licensing and the restrictions on distributing MySQL-based sample binaries, see source license checks.