将 order 模块接入 SCA Dubbo 和 Nacos Discovery 组件,同时将 Seata 修改成 SCA Seata 组件
This commit is contained in:
parent
4a2870e8e5
commit
60db9b9a77
@ -22,6 +22,8 @@
|
|||||||
<spring.cloud.alibaba.version>2.2.0.RELEASE</spring.cloud.alibaba.version>
|
<spring.cloud.alibaba.version>2.2.0.RELEASE</spring.cloud.alibaba.version>
|
||||||
<!-- RPC 相关 -->
|
<!-- RPC 相关 -->
|
||||||
<dubbo.version>2.7.1</dubbo.version>
|
<dubbo.version>2.7.1</dubbo.version>
|
||||||
|
<!-- Transaction 相关 -->
|
||||||
|
<seata.version>1.1.0</seata.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖管理 -->
|
<!-- 依赖管理 -->
|
||||||
@ -56,6 +58,14 @@
|
|||||||
<artifactId>dubbo</artifactId>
|
<artifactId>dubbo</artifactId>
|
||||||
<version>${dubbo.version}</version>
|
<version>${dubbo.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Transaction 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.seata</groupId>
|
||||||
|
<artifactId>seata-spring-boot-starter</artifactId>
|
||||||
|
<version>${seata.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
swagger:
|
|
||||||
enable: true
|
|
||||||
title: 订单子系统
|
|
||||||
description: 订单子系统
|
|
||||||
version: 1.0.0
|
|
||||||
base-package: cn.iocoder.mall.pay.application.controller
|
|
@ -76,23 +76,26 @@
|
|||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.seata</groupId>
|
|
||||||
<artifactId>seata-spring</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.seata</groupId>
|
|
||||||
<artifactId>seata-dubbo</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RPC 相关 -->
|
<!-- RPC 相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dubbo</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>dubbo</artifactId>
|
<artifactId>spring-cloud-starter-dubbo</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Registry 和 Config 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Transaction 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-seata</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dubbo</groupId>
|
<groupId>io.seata</groupId>
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
<artifactId>seata-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MQ 相关 -->
|
<!-- MQ 相关 -->
|
||||||
@ -107,16 +110,6 @@
|
|||||||
<artifactId>xxl-job-core</artifactId>
|
<artifactId>xxl-job-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Registry 和 Config 相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.curator</groupId>
|
|
||||||
<artifactId>curator-framework</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.curator</groupId>
|
|
||||||
<artifactId>curator-recipes</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 工具类相关 -->
|
<!-- 工具类相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
|
@ -1,48 +1,12 @@
|
|||||||
package cn.iocoder.mall.order.biz.config;
|
package cn.iocoder.mall.order.biz.config;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
|
||||||
import io.seata.rm.datasource.DataSourceProxy;
|
|
||||||
import io.seata.spring.annotation.GlobalTransactionScanner;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@MapperScan("cn.iocoder.mall.order.biz.dao") // 扫描对应的 Mapper 接口
|
@MapperScan("cn.iocoder.mall.order.biz.dao") // 扫描对应的 Mapper 接口
|
||||||
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
|
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
|
||||||
public class DatabaseConfiguration {
|
public class DatabaseConfiguration {
|
||||||
|
|
||||||
@Value("${spring.application.name}")
|
|
||||||
private String applicationId;
|
|
||||||
@Value("${seata.tx-service-group}")
|
|
||||||
private String txServiceGroup;
|
|
||||||
|
|
||||||
@Bean("druidDataSource")
|
|
||||||
@ConfigurationProperties("spring.datasource.druid")
|
|
||||||
public DruidDataSource druidDataSource(){
|
|
||||||
return DruidDataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource")
|
|
||||||
@Primary
|
|
||||||
@Bean("dataSource")
|
|
||||||
@DependsOn("druidDataSource") // 解决多数据源,循环依赖的问题。主要发生点在 DataSourceInitializerInvoker
|
|
||||||
public DataSource dataSource() {
|
|
||||||
DruidDataSource druidDataSource = druidDataSource();
|
|
||||||
return new DataSourceProxy(druidDataSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public GlobalTransactionScanner globalTransactionScanner() {
|
|
||||||
return new GlobalTransactionScanner(applicationId, txServiceGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@ public class OrderReturnServiceImpl implements OrderReturnService {
|
|||||||
private OrderItemMapper orderItemMapper;
|
private OrderItemMapper orderItemMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderReturnMapper orderReturnMapper;
|
private OrderReturnMapper orderReturnMapper;
|
||||||
|
@Autowired
|
||||||
@Reference(validation = "true")
|
|
||||||
private OrderLogisticsService orderLogisticsService;
|
private OrderLogisticsService orderLogisticsService;
|
||||||
|
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.PayRefundService.version}")
|
@Reference(validation = "true", version = "${dubbo.consumer.PayRefundService.version}")
|
||||||
private PayRefundService payRefundService;
|
private PayRefundService payRefundService;
|
||||||
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
|
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
spring:
|
|
||||||
# datasource
|
|
||||||
datasource:
|
|
||||||
url: jdbc:mysql://192.168.88.14:3306/mall_order?useSSL=false&useUnicode=true&characterEncoding=UTF-8
|
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
|
||||||
username: root
|
|
||||||
password: ${MALL_MYSQL_PASSWORD}
|
|
@ -5,15 +5,14 @@ spring:
|
|||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
username: root
|
username: root
|
||||||
password: ${MALL_MYSQL_PASSWORD}
|
password: ${MALL_MYSQL_PASSWORD}
|
||||||
application:
|
|
||||||
name: order-impl # 设置值保证程序启动时不报错,具体的值需要修改[nengjie]
|
|
||||||
|
|
||||||
# mybatis
|
# Spring Cloud 配置项
|
||||||
#mybatis:
|
cloud:
|
||||||
# config-location: classpath:mybatis-config.xml
|
nacos:
|
||||||
# mapper-locations: classpath:mapper/*.xml
|
# Spring Cloud Nacos Discovery 配置项
|
||||||
# type-aliases-package: cn.iocoder.mall.order.biz.dataobject
|
discovery:
|
||||||
#
|
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
|
||||||
|
|
||||||
# mybatis-plus
|
# mybatis-plus
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
@ -24,18 +23,22 @@ mybatis-plus:
|
|||||||
mapper-locations: classpath*:mapper/*.xml
|
mapper-locations: classpath*:mapper/*.xml
|
||||||
type-aliases-package: cn.iocoder.mall.order.biz.dataobject
|
type-aliases-package: cn.iocoder.mall.order.biz.dataobject
|
||||||
|
|
||||||
# dubbo
|
# Dubbo 配置项
|
||||||
dubbo:
|
dubbo:
|
||||||
application:
|
# Dubbo 注册中心
|
||||||
name: order-service
|
|
||||||
registry:
|
registry:
|
||||||
address: zookeeper://127.0.0.1:2181
|
address: spring-cloud://127.0.0.1:8848 # 指定 Dubbo 服务注册中心的地址
|
||||||
|
# Spring Cloud Alibaba Dubbo 专属配置
|
||||||
|
cloud:
|
||||||
|
subscribed-services: admin-application, user-application, product-application, promotion-application, pay-application # 设置订阅的应用列表,默认为 * 订阅所有应用
|
||||||
|
# Dubbo 提供者的协议
|
||||||
protocol:
|
protocol:
|
||||||
port: -1
|
|
||||||
name: dubbo
|
name: dubbo
|
||||||
|
port: -1
|
||||||
|
# Dubbo 提供服务的扫描基础包
|
||||||
scan:
|
scan:
|
||||||
base-packages: cn.iocoder.mall.order.biz.service
|
base-packages: cn.iocoder.mall.order.biz.service
|
||||||
|
# Dubbo 服务提供者的配置
|
||||||
provider:
|
provider:
|
||||||
filter: -exception
|
filter: -exception
|
||||||
CartService:
|
CartService:
|
||||||
@ -73,6 +76,12 @@ logging:
|
|||||||
# dao 开启 debug 模式 mybatis 输入 sql
|
# dao 开启 debug 模式 mybatis 输入 sql
|
||||||
cn.iocoder.mall.order.biz.dao: debug
|
cn.iocoder.mall.order.biz.dao: debug
|
||||||
|
|
||||||
# seata
|
# Seata 配置项
|
||||||
seata:
|
seata:
|
||||||
tx-service-group: my_test_tx_group
|
# Seata 注册中心配置项
|
||||||
|
registry:
|
||||||
|
type: nacos # 注册中心类型
|
||||||
|
nacos:
|
||||||
|
serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址
|
||||||
|
namespace: # Nacos 命名空间
|
||||||
|
cluster: default # 使用的 Seata 分组
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
transport {
|
|
||||||
# tcp udt unix-domain-socket
|
|
||||||
type = "TCP"
|
|
||||||
#NIO NATIVE
|
|
||||||
server = "NIO"
|
|
||||||
#enable heartbeat
|
|
||||||
heartbeat = true
|
|
||||||
#thread factory for netty
|
|
||||||
thread-factory {
|
|
||||||
boss-thread-prefix = "NettyBoss"
|
|
||||||
worker-thread-prefix = "NettyServerNIOWorker"
|
|
||||||
server-executor-thread-prefix = "NettyServerBizHandler"
|
|
||||||
share-boss-worker = false
|
|
||||||
client-selector-thread-prefix = "NettyClientSelector"
|
|
||||||
client-selector-thread-size = 1
|
|
||||||
client-worker-thread-prefix = "NettyClientWorkerThread"
|
|
||||||
# netty boss thread size,will not be used for UDT
|
|
||||||
boss-thread-size = 1
|
|
||||||
#auto default pin or 8
|
|
||||||
worker-thread-size = 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
service {
|
|
||||||
#vgroup->rgroup
|
|
||||||
vgroup_mapping.my_test_tx_group = "default"
|
|
||||||
#only support single node
|
|
||||||
default.grouplist = "180.167.213.26:8091"
|
|
||||||
#degrade current not support
|
|
||||||
enableDegrade = false
|
|
||||||
#disable
|
|
||||||
disable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
client {
|
|
||||||
async.commit.buffer.limit = 10000
|
|
||||||
lock {
|
|
||||||
retry.internal = 10
|
|
||||||
retry.times = 30
|
|
||||||
}
|
|
||||||
}
|
|
||||||
## transaction log store
|
|
||||||
store {
|
|
||||||
## store mode: file、db
|
|
||||||
mode = "file"
|
|
||||||
|
|
||||||
## file store
|
|
||||||
file {
|
|
||||||
dir = "file_store/data"
|
|
||||||
|
|
||||||
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
|
|
||||||
max-branch-session-size = 16384
|
|
||||||
# globe session size , if exceeded throws exceptions
|
|
||||||
max-global-session-size = 512
|
|
||||||
# file buffer size , if exceeded allocate new buffer
|
|
||||||
file-write-buffer-cache-size = 16384
|
|
||||||
# when recover batch read size
|
|
||||||
session.reload.read_size = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
## database store
|
|
||||||
db {
|
|
||||||
driver_class = ""
|
|
||||||
url = ""
|
|
||||||
user = ""
|
|
||||||
password = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
registry {
|
|
||||||
type = "file"
|
|
||||||
|
|
||||||
file {
|
|
||||||
name = "file.conf"
|
|
||||||
}
|
|
||||||
|
|
||||||
zk {
|
|
||||||
cluster = "default"
|
|
||||||
serverAddr = "192.168.88.10:2181"
|
|
||||||
session.timeout = 6000
|
|
||||||
connect.timeout = 2000
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,4 +16,17 @@
|
|||||||
<module>order-service-api</module>
|
<module>order-service-api</module>
|
||||||
<module>order-service-impl</module>
|
<module>order-service-impl</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.mall</groupId>
|
||||||
|
<artifactId>common-dependencies</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -31,8 +31,10 @@ dubbo:
|
|||||||
protocol:
|
protocol:
|
||||||
name: dubbo
|
name: dubbo
|
||||||
port: -1
|
port: -1
|
||||||
|
# Dubbo 提供服务的扫描基础包
|
||||||
scan:
|
scan:
|
||||||
base-packages: cn.iocoder.mall.pay.biz.service
|
base-packages: cn.iocoder.mall.pay.biz.service
|
||||||
|
# Dubbo 服务提供者的配置
|
||||||
provider:
|
provider:
|
||||||
filter: -exception
|
filter: -exception
|
||||||
PayTransactionService:
|
PayTransactionService:
|
||||||
|
Loading…
Reference in New Issue
Block a user