update to v1.4.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
.idea/
|
||||
logs/
|
||||
target/
|
||||
.txlcn/
|
||||
|
||||
*.iml
|
||||
*.versionsBackup
|
||||
@@ -17,6 +17,7 @@
|
||||
* 配置中心账号密码:nacos/nacos
|
||||
* APM监控账号密码:admin/admin
|
||||
* Grafana账号:zlt/zlt
|
||||
* txlcn事务管理器密码:admin
|
||||
* **演示环境有全方位的监控示例:日志系统 + APM系统 + GPE系统**
|
||||
* **[项目更新日志](https://www.kancloud.cn/zlt2000/microservices-platform/936235)**
|
||||
* **[文档更新日志](https://www.kancloud.cn/zlt2000/microservices-platform/936236)**
|
||||
@@ -59,6 +60,7 @@
|
||||
* 分布式任务调度器
|
||||
* 支持CI/CD持续集成(包括前端和后端)
|
||||
* 分布式高性能Id生成器
|
||||
* 分布式事务
|
||||
* **系统监控功能**
|
||||
* 服务调用链监控
|
||||
* 应用拓扑图
|
||||
@@ -96,7 +98,6 @@ central-platform -- 父项目,公共依赖
|
||||
│ │ ├─zlt-common-spring-boot-starter -- 封装通用操作逻辑
|
||||
│ │ ├─zlt-db-spring-boot-starter -- 封装数据库通用操作逻辑
|
||||
│ │ ├─zlt-log-spring-boot-starter -- 封装log通用操作逻辑
|
||||
│ │ ├─zlt-mq-spring-boot-starter -- 封装mq通用操作逻辑
|
||||
│ │ ├─zlt-redis-spring-boot-starter -- 封装Redis通用操作逻辑
|
||||
│ │ ├─zlt-ribbon-spring-boot-starter -- 封装Ribbon和Feign的通用操作逻辑
|
||||
│ │ ├─zlt-sentinel-spring-boot-starter -- 封装Sentinel的通用操作逻辑
|
||||
@@ -115,9 +116,12 @@ central-platform -- 父项目,公共依赖
|
||||
│ │ ├─log-center -- 日志中心[6200]
|
||||
│ ├─zlt-uaa -- spring-security认证中心[8000]
|
||||
│ ├─zlt-register -- 注册中心Nacos[8848]
|
||||
│ ├─zlt-search -- 搜索引擎一级工程
|
||||
│ ├─zlt-web -- 前端一级工程
|
||||
│ │ ├─back-web -- 后台前端[8066]
|
||||
│ ├─zlt-transaction -- 事务一级工程
|
||||
│ │ ├─txlcn-tm -- tx-lcn事务管理器[7970]
|
||||
│ ├─zlt-demo -- demo一级工程
|
||||
│ │ ├─txlcn-demo -- txlcn的demo
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
@@ -23,7 +23,7 @@
|
||||
<druid-starter>1.1.10</druid-starter>
|
||||
<jasypt.version>1.14</jasypt.version>
|
||||
<sharding-jdbc>2.0.3</sharding-jdbc>
|
||||
<security-oauth2.version>2.3.4.RELEASE</security-oauth2.version>
|
||||
<security-oauth2.version>2.3.5.RELEASE</security-oauth2.version>
|
||||
<security-jwt.version>1.0.9.RELEASE</security-jwt.version>
|
||||
<redisson.version>3.9.1</redisson.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
@@ -35,6 +35,7 @@
|
||||
<spring-boot-admin.version>2.0.4</spring-boot-admin.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<commons-configuration.version>1.10</commons-configuration.version>
|
||||
<txlcn.version>5.0.2.RELEASE</txlcn.version>
|
||||
<platform-bom>Cairo-SR3</platform-bom>
|
||||
<spring-cloud-alibaba-dependencies.version>0.2.1.RELEASE</spring-cloud-alibaba-dependencies.version>
|
||||
<spring-boot-dependencies.version>2.0.8.RELEASE</spring-boot-dependencies.version>
|
||||
@@ -264,6 +265,21 @@
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>${commons-configuration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-tm</artifactId>
|
||||
<version>${txlcn.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-tc</artifactId>
|
||||
<version>${txlcn.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-txmsg-netty</artifactId>
|
||||
<version>${txlcn.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -351,9 +367,11 @@
|
||||
<module>zlt-job</module>
|
||||
<!-- 监控 -->
|
||||
<module>zlt-monitor</module>
|
||||
<!-- 搜索 -->
|
||||
<module>zlt-search</module>
|
||||
<!-- 事务 -->
|
||||
<module>zlt-transaction</module>
|
||||
<!-- 配置 -->
|
||||
<module>zlt-config</module>
|
||||
<!-- demo -->
|
||||
<module>zlt-demo</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>code-generator</artifactId>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>file-center</artifactId>
|
||||
<description>文件中心</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<description>业务中心</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-business</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>user-center</artifactId>
|
||||
<description>用户中心</description>
|
||||
|
||||
+1
-2
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<description>通用组件</description>
|
||||
@@ -18,7 +18,6 @@
|
||||
<module>zlt-log-spring-boot-starter</module>
|
||||
<module>zlt-ribbon-spring-boot-starter</module>
|
||||
<module>zlt-auth-client-spring-boot-starter</module>
|
||||
<module>zlt-mq-spring-boot-starter</module>
|
||||
<module>zlt-sentinel-spring-boot-starter</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-common-spring-boot-starter</artifactId>
|
||||
<description>公共通用组件</description>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>zlt-mq-spring-boot-starter</artifactId>
|
||||
<description>消息队列通用组件</description>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-commons</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -26,7 +26,7 @@ ribbon.ReadTimeout=15000
|
||||
# 对当前实例的重试次数 默认0
|
||||
#ribbon.MaxAutoRetries=1
|
||||
# 切换实例的重试次数 默认1
|
||||
#ribbon.MaxAutoRetriesNextServer=2
|
||||
ribbon.MaxAutoRetriesNextServer=0
|
||||
|
||||
|
||||
##### feign配置
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<!-- txlcn分布式事务demo -->
|
||||
<module>txlcn-demo</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,48 @@
|
||||
[TOC]
|
||||
|
||||
## 一、说明
|
||||
|
||||
本demo是通过tx-lcn测试lcn模式的分布式事务,主要是模拟以下两个场景
|
||||
|
||||
1. `service-a` 调用`service-b`调用`service-c` 都成功
|
||||
2. `service-a` 调用`service-b`调用`service-c` 最后`service-a`抛出异常全部回滚
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 二、运行步骤
|
||||
|
||||
### 1. 初始化TxManager的数据
|
||||
|
||||
执行`zlt-doc\sql\tx-manager.sql`和`zlt-doc\sql\tx_logger.sql`脚本
|
||||
|
||||
### 2. 修改TxManager的配置
|
||||
|
||||
工程目录:`zlt-transaction\txlcn-tm`,修改nacos、数据库和redis
|
||||
|
||||
### 2. 启动TxManager
|
||||
|
||||
工程目录:`zlt-transaction\txlcn-tm`
|
||||
|
||||
### 3. 初始化demo的数据
|
||||
|
||||
执行`zlt-demo\txlcn-demo\txlcn-demo.sql`脚本
|
||||
|
||||
### 4. 修改3个服务的配置
|
||||
|
||||
`nacos`地址和数据库地址
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 三、启动模块与测试
|
||||
|
||||
### 1. 正常提交事务
|
||||
访问 发起方提供的Rest接口 `/txlcn?value=the-value`。发现事务全部提交
|
||||

|
||||
|
||||
### 2. 回滚事务
|
||||
访问 发起方提供的Rest接口 `/txlcn?value=the-value&ex=throw`。发现发起方由本地事务回滚,而参与方ServiceB、ServiceC,由于TX-LCN的协调,数据也回滚了。
|
||||

|
||||
@@ -0,0 +1,39 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-demo</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<description>txlcn分布式事务demo</description>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<!-- 公共 -->
|
||||
<module>txlcn-demo-common</module>
|
||||
<!-- 服务a -->
|
||||
<module>txlcn-demo-spring-service-a</module>
|
||||
<!-- 服务b -->
|
||||
<module>txlcn-demo-spring-service-b</module>
|
||||
<!-- 服务c -->
|
||||
<module>txlcn-demo-spring-service-c</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,69 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>txlcn-demo-common</artifactId>
|
||||
<name>demo-common</name>
|
||||
<description>demo-common project for Spring Boot</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-tc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-txmsg-netty</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-config</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-log-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-db-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-ribbon-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-sentinel-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.txlcn.demo.common.db.domain;
|
||||
|
||||
import com.codingapi.txlcn.common.util.id.RandomUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class Demo {
|
||||
private Long id;
|
||||
private String kid = RandomUtils.randomKey();
|
||||
private String demoField;
|
||||
private String groupId;
|
||||
private Date createTime;
|
||||
private String appName;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package org.txlcn.demo.common.db.mapper;
|
||||
|
||||
import org.txlcn.demo.common.db.domain.Demo;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseDemoMapper {
|
||||
|
||||
@Insert("insert into t_demo(kid, demo_field, group_id, create_time,app_name) values(#{kid}, #{demoField}, #{groupId}, #{createTime},#{appName})")
|
||||
void save(Demo demo);
|
||||
|
||||
@Delete("delete from t_demo where id=#{id}")
|
||||
void deleteByKId(Long id);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.txlcn.demo.common.spring;
|
||||
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@ComponentScan
|
||||
@Configuration
|
||||
@EnableFeignClients
|
||||
public class FeignConfiguration {
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.txlcn.demo.common.spring;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@FeignClient(value = "txlcn-demo-spring-service-b", fallback = ServiceBFallback.class)
|
||||
public interface ServiceBClient {
|
||||
|
||||
@GetMapping("/rpc")
|
||||
String rpc(@RequestParam("value") String name);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.txlcn.demo.common.spring;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 19-2-19 下午1:53
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Component
|
||||
public class ServiceBFallback implements ServiceBClient {
|
||||
@Override
|
||||
public String rpc(String name) {
|
||||
return "fallback";
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.txlcn.demo.common.spring;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@FeignClient(value = "txlcn-demo-spring-service-c", fallback = ServiceCFallback.class)
|
||||
public interface ServiceCClient {
|
||||
|
||||
@GetMapping("/rpc")
|
||||
String rpc(@RequestParam("value") String name);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.txlcn.demo.common.spring;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 19-2-19 下午1:53
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ServiceCFallback implements ServiceCClient {
|
||||
@Override
|
||||
public String rpc(String name) {
|
||||
return "fallback";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.txlcn.demo.common.spring.FeignConfiguration
|
||||
@@ -0,0 +1,29 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>txlcn-demo-spring-service-a</artifactId>
|
||||
<name>txlcn-demo-spring-service-a</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.txlcn.demo;
|
||||
|
||||
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableDistributedTransaction
|
||||
public class ServiceAApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceAApplication.class, args);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package org.txlcn.demo.servicea;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@RestController
|
||||
public class DemoController {
|
||||
|
||||
private final DemoService demoService;
|
||||
|
||||
@Autowired
|
||||
public DemoController(DemoService demoService) {
|
||||
this.demoService = demoService;
|
||||
}
|
||||
|
||||
@RequestMapping("/txlcn")
|
||||
public String execute(@RequestParam("value") String value, @RequestParam(value = "ex", required = false) String exFlag
|
||||
, @RequestParam(value = "f", required = false) String flag) {
|
||||
return demoService.execute(value, exFlag, flag);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.txlcn.demo.servicea;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.txlcn.demo.common.db.mapper.BaseDemoMapper;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Mapper
|
||||
public interface DemoMapper extends BaseDemoMapper {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.txlcn.demo.servicea;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
public interface DemoService {
|
||||
|
||||
String execute(String value, String ex, String flag);
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package org.txlcn.demo.servicea;
|
||||
|
||||
import com.codingapi.txlcn.common.util.Transactions;
|
||||
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
|
||||
import com.codingapi.txlcn.tracing.TracingContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.txlcn.demo.common.db.domain.Demo;
|
||||
import org.txlcn.demo.common.spring.ServiceBClient;
|
||||
import org.txlcn.demo.common.spring.ServiceCClient;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
@Resource
|
||||
private DemoMapper demoMapper;
|
||||
@Resource
|
||||
private ServiceBClient serviceBClient;
|
||||
@Resource
|
||||
private ServiceCClient serviceCClient;
|
||||
|
||||
@LcnTransaction
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public String execute(String value, String exFlag, String flag) {
|
||||
String dResp = serviceBClient.rpc(value);
|
||||
// step2. call remote ServiceB
|
||||
String eResp = serviceCClient.rpc(value);
|
||||
// step3. execute local transaction
|
||||
Demo demo = new Demo();
|
||||
demo.setGroupId(TracingContext.tracing().groupId());
|
||||
demo.setDemoField(value);
|
||||
demo.setCreateTime(new Date());
|
||||
demo.setAppName(Transactions.getApplicationId());
|
||||
demoMapper.save(demo);
|
||||
|
||||
// 置异常标志,DTX 回滚
|
||||
if (Objects.nonNull(exFlag)) {
|
||||
throw new IllegalStateException("by exFlag");
|
||||
}
|
||||
|
||||
return dResp + " > " + eResp + " > " + "ok-service-a";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://${zlt.datasource.ip}:3306/txlcn-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
|
||||
## tx-manager 配置
|
||||
tx-lcn:
|
||||
ribbon:
|
||||
loadbalancer:
|
||||
dtx:
|
||||
enabled: true
|
||||
logger:
|
||||
enabled: true
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/tx_logger?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 12011
|
||||
|
||||
zlt:
|
||||
nacos:
|
||||
server-addr: 192.168.28.130:8848
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: txlcn-demo-spring-service-a
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
@@ -0,0 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-demo-spring-service-b</artifactId>
|
||||
<name>txlcn-demo-spring-service-b</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.txlcn.demo;
|
||||
|
||||
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableDistributedTransaction
|
||||
public class ServiceBApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceBApplication.class, args);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@RestController
|
||||
public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
@GetMapping("/rpc")
|
||||
public String rpc(@RequestParam("value") String value, HttpServletRequest servletRequest) {
|
||||
return demoService.rpc(value);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.txlcn.demo.common.db.mapper.BaseDemoMapper;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Mapper
|
||||
public interface DemoMapper extends BaseDemoMapper {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
public interface DemoService {
|
||||
|
||||
String rpc(String value);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
import com.codingapi.txlcn.common.util.Transactions;
|
||||
import com.codingapi.txlcn.tc.annotation.DTXPropagation;
|
||||
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
|
||||
import com.codingapi.txlcn.tc.annotation.TxcTransaction;
|
||||
import com.codingapi.txlcn.tracing.TracingContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.txlcn.demo.common.db.domain.Demo;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
@Resource
|
||||
private DemoMapper demoMapper;
|
||||
|
||||
@Override
|
||||
@LcnTransaction
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String rpc(String value) {
|
||||
Demo demo = new Demo();
|
||||
demo.setGroupId(TracingContext.tracing().groupId());
|
||||
demo.setDemoField(value);
|
||||
demo.setAppName(Transactions.getApplicationId());
|
||||
demo.setCreateTime(new Date());
|
||||
demoMapper.save(demo);
|
||||
return "ok-service-b";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://${zlt.datasource.ip}:3306/txlcn-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
|
||||
## tx-manager 配置
|
||||
tx-lcn:
|
||||
ribbon:
|
||||
loadbalancer:
|
||||
dtx:
|
||||
enabled: true
|
||||
logger:
|
||||
enabled: true
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/tx_logger?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 12002
|
||||
|
||||
zlt:
|
||||
nacos:
|
||||
server-addr: 192.168.28.130:8848
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: txlcn-demo-spring-service-b
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
@@ -0,0 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-demo-spring-service-c</artifactId>
|
||||
<name>txlcn-demo-spring-service-c</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>txlcn-demo-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.txlcn.demo;
|
||||
|
||||
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableDistributedTransaction
|
||||
public class ServiceCApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceCApplication.class, args);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package org.txlcn.demo.servicec;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@RestController
|
||||
public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
@GetMapping("/rpc")
|
||||
public String rpc(@RequestParam("value") String value) {
|
||||
return demoService.rpc(value);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.txlcn.demo.servicec;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.txlcn.demo.common.db.mapper.BaseDemoMapper;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Mapper
|
||||
public interface DemoMapper extends BaseDemoMapper {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.txlcn.demo.servicec;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
public interface DemoService {
|
||||
|
||||
String rpc(String value);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package org.txlcn.demo.servicec;
|
||||
|
||||
import com.codingapi.txlcn.common.util.Transactions;
|
||||
import com.codingapi.txlcn.tc.annotation.DTXPropagation;
|
||||
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
|
||||
import com.codingapi.txlcn.tc.annotation.TccTransaction;
|
||||
import com.codingapi.txlcn.tc.support.DTXUserControls;
|
||||
import com.codingapi.txlcn.tracing.TracingContext;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.txlcn.demo.common.db.domain.Demo;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
@Resource
|
||||
private DemoMapper demoMapper;
|
||||
|
||||
@Override
|
||||
@LcnTransaction
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String rpc(String value) {
|
||||
Demo demo = new Demo();
|
||||
demo.setDemoField(value);
|
||||
demo.setCreateTime(new Date());
|
||||
demo.setAppName(Transactions.getApplicationId());
|
||||
demo.setGroupId(TracingContext.tracing().groupId());
|
||||
demoMapper.save(demo);
|
||||
if ("456".equals(value)) {
|
||||
throw new IllegalStateException("by test");
|
||||
}
|
||||
return "ok-service-c";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://${zlt.datasource.ip}:3306/txlcn-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
|
||||
## tx-manager 配置
|
||||
tx-lcn:
|
||||
ribbon:
|
||||
loadbalancer:
|
||||
dtx:
|
||||
enabled: true
|
||||
logger:
|
||||
enabled: true
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/tx_logger?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
@@ -0,0 +1,14 @@
|
||||
server:
|
||||
port: 12003
|
||||
|
||||
zlt:
|
||||
nacos:
|
||||
server-addr: 192.168.28.130:8848
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: txlcn-demo-spring-service-c
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
@@ -0,0 +1,23 @@
|
||||
--
|
||||
-- Current Database: `txlcn-demo`
|
||||
--
|
||||
|
||||
CREATE DATABASE `txlcn-demo` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE `txlcn-demo`;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_demo`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_demo`;
|
||||
CREATE TABLE `t_demo` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`kid` varchar(45) DEFAULT NULL,
|
||||
`demo_field` varchar(255) DEFAULT NULL,
|
||||
`group_id` varchar(64) DEFAULT NULL,
|
||||
`unit_id` varchar(32) DEFAULT NULL,
|
||||
`app_name` varchar(128) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
|
||||
@@ -0,0 +1,19 @@
|
||||
CREATE DATABASE IF NOT EXISTS `tx-manager` DEFAULT CHARACTER SET = utf8;
|
||||
Use `tx-manager`;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for tx-manager
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `t_tx_exception`;
|
||||
CREATE TABLE `t_tx_exception` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`group_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
`unit_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
`mod_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
`transaction_state` tinyint(4) NULL DEFAULT NULL,
|
||||
`registrar` tinyint(4) NULL DEFAULT NULL,
|
||||
`remark` varchar(4096) NULL DEFAULT NULL,
|
||||
`ex_state` tinyint(4) NULL DEFAULT NULL COMMENT '0 未解决 1已解决',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE DATABASE IF NOT EXISTS `tx_logger` DEFAULT CHARACTER SET = utf8;
|
||||
Use `tx_logger`;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for t_logger
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `t_logger`;
|
||||
CREATE TABLE `t_logger` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`group_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`unit_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`tag` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`content` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`create_time` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-gateway</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-gateway</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>sc-gateway</artifactId>
|
||||
<description>spring cloud gateway网关</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-gateway</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zuul-gateway</artifactId>
|
||||
<description>zuul网关</description>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>job-admin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>job-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>job-executor-samples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-job</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>log-center</artifactId>
|
||||
<dependencies>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-monitor</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>sc-admin</artifactId>
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-search</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-transaction</artifactId>
|
||||
<description>事务</description>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<!-- tx-lcn事务管理器 -->
|
||||
<module>txlcn-tm</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,79 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-transaction</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>txlcn-tm</artifactId>
|
||||
<description>tx-lcn事务管理器</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-config</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-log-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codingapi.txlcn</groupId>
|
||||
<artifactId>txlcn-tm</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
|
||||
<imageTags>
|
||||
<imageTag>${project.version}</imageTag>
|
||||
<imageTag>latest</imageTag>
|
||||
</imageTags>
|
||||
<forceTags>true</forceTags>
|
||||
<baseImage>${docker.baseImage}</baseImage>
|
||||
<volumes>${docker.volumes}</volumes>
|
||||
<env>
|
||||
<JAVA_OPTS>${docker.java.opts}</JAVA_OPTS>
|
||||
</env>
|
||||
<entryPoint>["java ","$JAVA_OPTS ${docker.java.security.egd} ","-jar
|
||||
","/${project.build.finalName}.jar"]
|
||||
</entryPoint>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
</project>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.txlcn.tm;
|
||||
|
||||
import com.codingapi.txlcn.tm.config.EnableTransactionManagerServer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableTransactionManagerServer
|
||||
public class TransactionManagerApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TransactionManagerApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
##################
|
||||
# 你可以在 https://txlcn.org/zh-cn/docs/setting/manager.html 看到所有的个性化配置
|
||||
#################
|
||||
spring.profiles.active=dev
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://${zlt.datasource.ip}:3306/tx-manager?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=${zlt.datasource.username}
|
||||
spring.datasource.password=${zlt.datasource.password}
|
||||
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
|
||||
tx-lcn.logger.enabled=true
|
||||
tx-lcn.logger.driver-class-name=com.mysql.jdbc.Driver
|
||||
tx-lcn.logger.jdbc-url=jdbc:mysql://${zlt.datasource.ip}:3306/tx_logger?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
|
||||
tx-lcn.logger.username=${zlt.datasource.username}
|
||||
tx-lcn.logger.password=${zlt.datasource.password}
|
||||
|
||||
# redis 的设置信息. 线上请用Redis Cluster
|
||||
spring.redis.host=${zlt.redis.host}
|
||||
spring.redis.port=${zlt.redis.port}
|
||||
spring.redis.password=
|
||||
|
||||
# TM后台登陆密码,默认值为codingapi
|
||||
tx-lcn.manager.admin-key=admin
|
||||
|
||||
# 分布式事务执行总时间(ms). 默认为8000
|
||||
tx-lcn.manager.dtx-time=15000
|
||||
@@ -0,0 +1,5 @@
|
||||
spring.application.name=TX-Manager
|
||||
server.port=7970
|
||||
|
||||
zlt.nacos.server-addr=192.168.28.130:8848
|
||||
spring.cloud.nacos.discovery.server-addr=${zlt.nacos.server-addr}
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-uaa</artifactId>
|
||||
<description>认证中心</description>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>zlt-web</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>back-web</artifactId>
|
||||
<description>后台管理前端</description>
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.central.web;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
*/
|
||||
@Configuration
|
||||
@SpringBootApplication
|
||||
public class BackWebApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
+4
-4
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>com.zlt</groupId>
|
||||
<artifactId>central-platform</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.4.0</version>
|
||||
</parent>
|
||||
<artifactId>zlt-web</artifactId>
|
||||
<description>前端</description>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>back-web</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>back-web</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user