zoukankan      html  css  js  c++  java
  • 分布式事务框架搭建txlcn笔记

    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









  • 相关阅读:
    java_oop_方法2
    POJ 3276 Face The Right Way(反转)
    POJ 3276 Face The Right Way(反转)
    POJ 2566 Bound Found(尺取法,前缀和)
    POJ 2566 Bound Found(尺取法,前缀和)
    POJ 3320 Jessica's Reading Problem(尺取法)
    POJ 3320 Jessica's Reading Problem(尺取法)
    POJ 3061 Subsequence(尺取法)
    POJ 3061 Subsequence(尺取法)
    HDU 1222 Wolf and Rabbit(欧几里得)
  • 原文地址:https://www.cnblogs.com/wanqiang/p/15802746.html
Copyright © 2011-2022 走看看