|
2 | 2 |
|
3 | 3 | "LCN并不生产事务,LCN只是本地事务的搬用工" |
4 | 4 |
|
| 5 | +## 官方网址 |
5 | 6 |
|
6 | | -## maven 中心库地址 |
| 7 | +[www.txlcn.org](http://www.txlcn.org) |
| 8 | + |
| 9 | + |
| 10 | +## 框架特点 |
| 11 | + |
| 12 | +1. 支持各种基于spring的db框架 |
| 13 | +2. 兼容SpringCloud、Dubbo |
| 14 | +3. 使用简单,低依赖,代码完全开源 |
| 15 | +4. 基于切面的强一致性事务框架 |
| 16 | +5. 高可用,模块可以依赖Dubbo或SpringCloud的集群方式做集群化,TxManager也可以做集群化 |
| 17 | +6. 支持本地事务和分布式事务共存 |
| 18 | +7. 支持事务补偿机制,增加事务补偿决策提醒 |
| 19 | +8. 增加插件拓展机制 |
| 20 | + |
| 21 | + |
| 22 | +## 原理介绍 |
| 23 | + |
| 24 | +[原理介绍](https://github.com/codingapi/tx-lcn/wiki) |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## 目录说明 |
| 29 | + |
| 30 | +transaction-dubbo LCN dubbo rpc框架扩展支持 |
| 31 | + |
| 32 | +transaction-springcloud LCN springcloud rpc框架扩展支持 |
| 33 | + |
| 34 | +tx-client 是LCN核心tx模块端控制框架 |
| 35 | + |
| 36 | +tx-manager 是LCN 分布式事务协调器 |
| 37 | + |
| 38 | +tx-plugins-db 是LCN 对关系型数据库的插件支持 |
| 39 | + |
| 40 | +tx-plugins-nodb 是LCN 对于无数据库模块的插件支持 |
| 41 | + |
| 42 | +tx-plugins-redis 是LCN 对于redis模块的插件支持(功能暂未实现) |
| 43 | + |
| 44 | + |
| 45 | +## 使用说明 |
| 46 | + |
| 47 | +分布式事务发起方: |
7 | 48 |
|
8 | 49 | ``` |
9 | 50 |
|
10 | | -<dependency> |
11 | | - <groupId>com.codingapi</groupId> |
12 | | - <artifactId>tx-client</artifactId> |
13 | | - <version>1.0.0</version> |
14 | | -</dependency> |
15 | | -
|
16 | | -<dependency> |
17 | | - <groupId>com.codingapi</groupId> |
18 | | - <artifactId>tx-plugins-nodb</artifactId> |
19 | | - <version>1.0.0</version> |
20 | | -</dependency> |
21 | | -
|
22 | | -<dependency> |
23 | | - <groupId>com.codingapi</groupId> |
24 | | - <artifactId>tx-plugins-db</artifactId> |
25 | | - <version>1.0.0</version> |
26 | | -</dependency> |
27 | | -
|
28 | | -<dependency> |
29 | | - <groupId>com.codingapi</groupId> |
30 | | - <artifactId>transaction-springcloud</artifactId> |
31 | | - <version>1.0.0</version> |
32 | | -</dependency> |
33 | | -
|
34 | | -
|
35 | | -<dependency> |
36 | | - <groupId>com.codingapi</groupId> |
37 | | - <artifactId>transaction-dubbo</artifactId> |
38 | | - <version>1.0.0</version> |
39 | | -</dependency> |
| 51 | + @Override |
| 52 | + @TxTransaction |
| 53 | + @Transactional |
| 54 | + public boolean hello() { |
| 55 | + //本地调用 |
| 56 | + testDao.save(); |
| 57 | + //远程调用方 |
| 58 | + boolean res = test2Service.test(); |
| 59 | + //模拟异常 |
| 60 | + int v = 100/0; |
| 61 | + return true; |
| 62 | + } |
| 63 | + |
| 64 | + |
| 65 | +``` |
40 | 66 |
|
| 67 | +分布式事务被调用方(test2Service的业务实现类) |
41 | 68 | ``` |
42 | 69 |
|
43 | | -## 原理介绍 |
| 70 | + @Override |
| 71 | + @Transactional |
| 72 | + public boolean test() { |
| 73 | + //本地调用 |
| 74 | + testDao.save(); |
| 75 | + return true; |
| 76 | + } |
| 77 | +
|
| 78 | +``` |
| 79 | + |
| 80 | +如上代码执行完成以后两个模块都将回滚事务。 |
44 | 81 |
|
45 | | -[LCN原理](https://github.com/codingapi/tx-lcn/wiki/LCN原理) |
| 82 | +说明:在使用LCN分布式事务时,只需要将事务的开始方法添加`@TxTransaction`注解即可。详细见demo教程 |
46 | 83 |
|
47 | 84 |
|
48 | | -## demo教程 |
| 85 | +## demo演示教程 |
49 | 86 |
|
50 | 87 | 每个demo下有区分为 jdbc/hibernate/mybatis不同框架的版本demo |
51 | 88 |
|
|
54 | 91 | [dubbo版本](https://github.com/codingapi/dubbo-lcn-demo) |
55 | 92 |
|
56 | 93 |
|
57 | | -更多资料维护中... |
| 94 | +技术交流群:554855843 |
0 commit comments