Saga | 中文
![Coverage Status](https://camo.githubusercontent.com/d07eef850d540261517ff1fae07ebad8db8f14ec43ee130c4957ae8df514c6e5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6170616368652f696e63756261746f722d73657276696365636f6d622d736167612f62616467652e7376673f6272616e63683d6d6173746572)
![Gitter](https://camo.githubusercontent.com/a80873c07e80c783d7344a4cd99579563e0d624325c1ef3e79cb0feb16ea83de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53657276696365436f6d622d4769747465722d6666363962342e737667)
Apache ServiceComb (incubating) Saga is an eventually data consistency solution for micro-service applications. Transactions are commited directly in the try phase and compensated in reverse order in the rollback phase comparing to TCC.
- High availability. The coordinator is stateless and thus can have multiple instances.
- High reliability. All transaction events are stored in database permanently.
- High performance. Transaction events are reported to coordinator via gRPC and transaction payloads are serialized/deserialized by Kyro.
- Low invasion. All you need to do is add 2-3 annotations and the corresponding compensate methods.
- Easy to deploy. All components can boot via docker.
- Support both forward(retry) and backward(compensate) recovery.
Saga is composed of alpha and omega.
- The alpha plays as the coordinator. It is responsible for the management of transactions.
- The omega plays as an agent inside the micro-service. It intercepts incoming/outgoing requests and reports transaction events to alpha.
The following diagram shows the relationships among alpha, omega and services.
See Saga Pack Design for details.
- For ServiceComb Java Chassis application, please see Booking Demo for details.
- For Spring applications, please see Booking Demo for details.
- For Dubbo applications, please see Dubbo Demo for details.
- Build the source code and run the tests
$ mvn clean install
- Build the source demo docker images and run the accept tests
$ mvn clean install -Pdemo,docker
- Current Saga code supports Spring Boot 1.x and Spring Boot 2.x at the same time, saga uses Spring Boot 1.x by default, you can use -Pspring-boot-2 to switch Spring Boot version to 2.x.
Since Spring Boot supports JDK9 since 2.x, if you want to build and run test the Saga with JDK9 or JDK10, you need to use the spring-boot-2 profile.
$ mvn clean install -Pdemo,docker,spring-boot-2
How to build and use can refer to User Guide.
See Pull Request Guide for details.
Licensed under an Apache 2.0 license.