1. Ali distributed seata entry Affairs (Pit)
1.1 Introduction
seata
Isfeascar
renamed from, this is Ali out of the open source distributed transaction in early 2007 framework, originally wanted to study just came out next, was delayed until now, currently0.8.0
version, see the version you know this is a relatively new project, but now there are tens of thousands of the Star, shows the influence of Ali. But while Ali has endorsed the digging had to dig, it declared that it is relatively simple integration, is now due to its advantages of incomplete documentation, several title of the document did not point into content, do not know why deleted, it may be updated faster, keep up the rhythm simply delete the document [manual funny]
1.2. Quick Start
1.2.1. 找 Demo
- In general, we want to integrate third-party middleware is certainly going to find that the official demo, the official document below, I found Seata the Samples , see the current version is
0.8.0
1.2.2. Contents analysis
Because I used SpringCloud the set, did not use dubbo, so I did not run on dubbo of the
- Look it an example of the directory structure, we also know it can probably run it is valid
Of primary concern here is actually a document, although pitiful, but I found a can directly point here
1.2.3 Runspringboot-mybatis
- My first run was the least dependent
springboot-mybatis
only need to open a server, configure the local database, and set up tables can run, this is actually nothing to say, I run very smoothly, just run the directory sql directory under theall_in_one.sql
inside of all the statements, it will help you build the database insert basic data , as the end of the download service can click here to download - window system directly above the server unzip the bag double-click operation
seata-server.bat
, liunx system runseata-server.sh
this, it is enabled by default8091
port configuration files in/conf
the directory, major changes are neededfile.conf
andrefistry.conf
, after will be talked about List of Figures except under the following
common
do not need to run, the other four are up and running, and then calllocalhost:8084/api/business/purchase/commit
, check the database will find the order table to add data, storage table deducted inventory, account was deducted money
Then the case is a test rollback
As the interface calls
localhost:8084/api/business/purchase/rollback
, look ataccount
the system
Is actually a special user thrown exceptions caused by a rollback, you can be marked with a breakpoint before throwing an exception, then you will find to run, go to the database, inventory has been deducted, the order has been added,
undo_log
the table has the recording , which involves its rollback principle, probably say, has been running through sql logging, succeeded delete the log, failed to roll back the log data, and then delete the log, so anyway, log it should not exist, if there is an abnormal downtime help system, start and should continue to be rolled back
1.2.4. Small summary
- By fast start, we can quickly run success of its demo, the pit is currently not met, but the default configuration so far we have used, have not seen the basic how it changes the configuration, see next configuration Seata file
1.3. Seata
Configuration File
1.3.1. registry.conf
- Official documents address
- He specifically mentioned sentence here
service.vgroup_mapping this configuration, in the default Spring Cloud $ {spring.application.name} -fescar-service-group, may be covered by the specified application.properties spring.cloud.alibaba.seata.tx-service-group this property , but it must be consistent and file.conf in, otherwise it will prompt
no available server to connect
Finally, I run
springcloud-eureak-seata
when she encountered, and here it reflects the lack of documentation, I think each of the following examples should put a Notes document it, and hold each example below, wiki Rideau write about is good too, we are not developers, to seata not familiar, especially its configuration, the two main profilesregistry.conf
andfile.conf
the various systems are present, but the description of its precautions and onlySample
project in thequick-integration-with-spring-cloud.md
documents mentioned in the sentence, for just the contact person for this project very friendly- This file is used to specify the registry and configuration files , default is the local file storage, so the beginning of mybatis project we did not feel the need to rely on, then the above phrase is also successful with crooked remind me, so I did not think service brought out problems
The file can choose
file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
these registries, specifyfile、nacos 、apollo、zk、consul、etcd3
these configuration files are stored, so as to remind eureka type with a registry change here remember
1.3.2. file.conf
- Used to specify the TC (Transaction Coordinator) related attributes
- It also wrote
如果使用注册中心也可以将配置添加到配置中心
, I have to Tucao, I useapollo
as a distribution center, how to put this configuration fileapollo
to go, there is also no documentation, then I have to look up the source code to study What is important here used in the demo in property
service.vgroup_mapping.my_test_tx_group
, the value of this key is equivalent to the service name of the server, in effect Eureka, equivalent to the following
Eureka useless if this registry, we will need to fill in the server address, the corresponding
service.default.grouplist
values
As there are n number of other properties Sorry, no documents, in addition to understand from the literal meaning, you do not know to look at the source code, anyway, I do not write the document
1.4. SpringCloud integration
1.4.1. Pit
- Ready to run
springcloud-eureka-seata
, I first of all run, reportedno available server to connect
since been re-check the configuration where the pair is not? Tangled for a long time, I finally react, this is not the server - In the provider modifies
type = "eureka"
or incorrect report, but I have been debug, I know that is not the original problem, the ultimate solution is run locally, the service side offile.conf
theservice.default.grouplist = "172.16.100.141:8091"
address into the network address , do not use127.0.0.1
, step two Hang finally commissioning a success, the demo is successfully up and running, after the challenge is to integrate into your own project - Here what should Tucao, in addition to quick start, no other integrated document, which is in addition to references jar package also need to do the only reference is the
Sample
project, this project integrated pit tomorrow continue to step up free
1.5 Summary
- The technical idea of the project is good, distributed transaction mode is also more than one (although its documentation to demonstrate such a kind), I believe it will continue to put good ideas incorporated Ali distributed transaction, or worth the wait