ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

分布式事务框架搭建txlcn--笔记

2022-01-14 17:33:00  阅读:181  来源: 互联网

标签:5.0 txlcn -- manager tm com tc 分布式


1.txlcn 分为两部分   

txlcn-tm 和
txlcn-tc

以下简称 tm 和 tc
-------------------------------------tm----------------------------------
1.添加 依赖
<dependency>
<groupId>com.codingapi.txlcn</groupId>
<artifactId>txlcn-tm</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>

2.配置文件: application.yml 和 application.properties 都可以,以下是
application.yml
server:
# 服务端口号
port: 7970
spring:
application:
# 服务名称 - 服务之间使用名称进行通讯
name: service-manager
#数据库相关配置
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/tx-manager?useUnicode=true&characterEncoding=UTF-8&&serverTimezone=UTC
username: root
password: 123456
redis:
host: 127.0.0.1
port: 6379
pool:
max-wait: -1
max-idle: 10
max-active: 500
timeout: 5000
main:
allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
logging:
level:
com.example: DEBUG
jdbc.sqltiming: DEBUG
tx-lcn :
logger :
enabled : true
manager :
admin-key : admin

eureka:
client:
service-url:
# 填写注册中心服务器地址
defaultZone: http://localhost:8761/eureka
instance:
# 使用ip地址注册到注册中心
prefer-ip-address: true
# 注册中心列表中显示的状态参数
instance-id: ${spring.application.name}:${server.port}
#instance-id: service-order:8082
status-page-url: http://${spring.cloud.client.ipAddress}:${server.port}/swagger-ui.html
#Mybatis配置
mybatis-plus:
mapper-locations: classpath:/mappers/*.xml
type-aliases-package: com.example.serviceorder
3.启动类
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagerServer
public class ManagerApplication {

public static void main(String[] args) {
SpringApplication.run(ManagerApplication.class, args);
}

}
4.执行sql 建表

准备工作:去自己本地maven 仓库 ,后面这个目录  com\codingapi\txlcn\txlcn-tm\5.0.2.RELEASE

 解压:txlcn-tm-5.0.2.RELEASE.jar,拿到 tx-manager.sql 执行:建库建表

 

5;启动 tm 服务

http://127.0.0.1:7970/ 

 

 

 


默认密码::codingpi     
可以通过以下配置修改密码:

tx-lcn :
  manager :
    admin-key : codingpi




--------------------------------------tc--------------------------------------
tc 指需要使用分布式事务的模块,有几个模块使用分布式事务就添加几个。
1.添加 依赖
<!-- lcn-->
<dependency>
<groupId>com.codingapi.txlcn</groupId>
<artifactId>txlcn-tc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.codingapi.txlcn</groupId>
<artifactId>txlcn-txmsg-netty</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
2.配置文件(事务管理器的地址)
tx-lcn :
client :
manager-address : 127.0.0.1:8070

3.启动类
添加
@EnableDistributedTransaction 注解

4.方法上添加(需要使用分布式事务的方法都添加)
@LcnTransaction
@Transactional









标签:5.0,txlcn,--,manager,tm,com,tc,分布式
来源: https://www.cnblogs.com/wanqiang/p/15802746.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有