Table of contents
1.1 In order to enable the seata cluster to share data
1.2 Modify the registration center and configuration center
1.3 Put the configuration into the configuration center
2. Build microservices to connect to seata
2.2 The principle of seata solving distributed transactions
1. Build Seata service
seata supports cluster mode from 1.3 onwards. If we need to use seata version 1.3.0, then we need to specify the storage source of the seata cluster.
1.1 In order to enable the seata cluster to share data
download seata
Modify file.conf file
Downloading the seata source code requires the table structure inside
Unzip
Copy the script to seata-server
Find the table corresponding to the database under db and read it into navicat's seata database -----note that it must correspond to the file database configured above
Place the mysql8.0jar package in the lib directory
1.2 Modify the registration center and configuration center
(1) Modify registry.conf
1.3 Put the configuration into the configuration center
(1) Find config.txt under script
(2) Modify config.txt
(3) Put the modified configuration above into the configuration center
(4) Check whether the configuration is successful
(5) Start the seata service
(6) Check whether the service is started successfully
2. Build microservices to connect to seata
Create a table log in each of the above three libraries.
Data rollback log. Pre-snapshot and post-snapshot. ----Regardless of whether it is submitted or rolled back, the records in this table will be deleted.
2.1 Configure microservices
(1) Add dependencies
<!--seata 一定要保证和seata服务的版本匹配-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
(2) application.yml arrangement seata
! ! ! ! ! ! ! ! ! ! ! Among the heavy weight! ! ! ! ! ! ! ! !
(3) Add annotation @GlobalTransactional to the caller TM
After each module is added with configuration like this, the project must be run with jdk1.8, otherwise there will be a version mismatch.
(4) Test