:-: 
架構圖
在課件代碼中已經提供了對應的模塊,如下圖:

(1)三個模塊都已經被注冊到nacos中。
(2)通過order模塊下單(即order模塊為訪問入口),order模塊通過openfeign調用storage模塊進行庫存操作,order模塊通過openfeign調用account模塊進行賬戶金額操作。
<br/>
具體的模塊創建過程這里就不一一贅述了,下面主要是講與seata相關的一些配置。
**1. 三個模塊都要添加seata相關依賴**
```xml
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<exclusions>
<exclusion>
<artifactId>seata-all</artifactId>
<groupId>io.seata</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-all</artifactId>
<version>1.0.0</version><!--版本最好與安裝得的seata版本一致-->
</dependency>
...
```
**2. 三個模塊都要設置seata的事務組名稱**
*`application.yml`*
```yml
spring:
cloud:
alibaba:
seata:
tx-service-group: fsp_tx_group
#seata事務組名稱
#它就是seata安裝目錄的 %SEATA_HOME%\conf\file.conf 文件中的vgroup_mapping.my_test_tx_group屬性值
```
**3. 三個模塊都要配置`resources/file.conf`配置文件**

三個模塊的`file.conf`配置內容都是一樣的,如下:
```conf
service {
#transaction service group mapping
#這里設置的事務組名稱是個性的,即可以自由定義該屬性名稱,可以與其他模塊相同也可以不同
#fsp_tx_group是seata安裝目錄的 %SEATA_HOME%\conf\file.conf 文件中的vgroup_mapping.my_test_tx_group屬性值
vgroup_mapping.fsp_tx_group = "default"
#only support when registry.type=file, please don't set multiple addresses
default.grouplist = "127.0.0.1:8091"
#disable seata
disableGlobalTransaction = false
}
## transaction log store, only used in seata-server
store {
## store mode: file、db
mode = "db"
## file store property
file {
## store location dir
dir = "sessionStore"
}
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
datasource = "dbcp"
## mysql/oracle/h2/oceanbase etc.
db-type = "mysql"
driver-class-name = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/seata"
user = "root"
password = "root"
}
}
```
**4. 三個模塊都要配置`resources/registry.conf`配置文件**

三個模塊的`registry.conf`配置內容都是一樣的,如下:
```conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
serverAddr = "localhost:8848"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}
```
- 微服務
- 微服務是什么?
- 微服務架構
- 微服務優缺點
- 微服務技術棧
- 微服務框架對比
- SpringCloud
- SpringCloud是什么
- SpringCloud與SpringBoot對比
- SpringCloud與Dubbo對比
- Rest微服務案例
- 總體介紹
- 父工程構建步驟
- 公共模塊構建步驟
- 服務端模塊構建步驟
- 消費端模塊構建步驟
- Eureka服務注冊與發現
- Eureka是什么
- Eureka原理
- Eureka注冊服務中心構建
- 向Eureka注冊已有微服務
- Eureka的自我保護機制
- Eureka服務發現
- Eureka集群配置
- Eureka與Zookeeper對比
- Ribbon負載均衡
- Ribbon是什么
- Ribbon負載均衡演示
- 構建服務端模塊
- 構建消費端模塊
- Ribbon核心組件IRule
- 自定義負載均衡策略
- Ribbon均衡策略優先級
- 輪詢策略算法
- OpenFeign負載均衡
- OpenFeign是什么
- 負載均衡演示
- 日志打印功能
- 導出功能
- Hystrix斷路器
- Hystrix是什么
- 服務熔斷
- Hystrix服務端構建
- 服務熔斷演示
- 服務熔斷類型
- HystrixProperty配置匯總
- 服務降級
- Hystrix客戶端構建
- 服務降級演示
- fallbackFactory
- 熔斷與降級
- 服務監控
- 網關服務Zuul
- Zuul是什么
- Zuul路由服務構建
- 設置訪問映射規則
- Config分布式配置中心
- Config分布式配置中心是什么
- Config服務端與Git通信
- Config客戶端獲取配置
- Config客戶端動態刷新
- Bus消息總線
- Bus消息總線是什么
- Bus消息總線原理
- 廣播通知設計思想
- 廣播通知演示
- 定點通知演示
- Stream消息驅動
- 為什么要引入Stream
- Stream消息驅動是什么
- Stream設計思想
- Stream流程和注解
- Stream案例演示
- 重復消費問題
- 消息持久化
- Sleuth分布式鏈路跟蹤
- Sleuth是什么
- 搭建鏈路監控
- SpringCloud Alibaba
- Nacos注冊與配置中心
- Nacos是什么
- 安裝并運行Nacos
- Nacos注冊中心
- 服務端入住Nacos
- 消費端入住Nacos
- Nacos負載均衡演示
- 服務注冊中心對比
- Nacos的AP和CP轉化
- Nacos配置中心
- 基礎配置演示
- Nacos分類配置
- Nacos集群搭建
- Sentinel實現熔斷與限流
- Sentinel是什么
- Sentinel環境搭建
- Sentinel監控微服務演示
- Sentinel流控規則
- 流量監控的作用
- 設置流控規則
- Sentinel降級規則
- 熔斷降級作用
- 設置降級規則
- Sentinel熱點限流
- 什么是熱點
- 設置熱點限流
- Sentinel系統限流
- @SentinelResource
- @SentinelResource屬性
- @SentinelResource限流演示
- @SentinelResource熔斷演示
- 規則持久化
- 熔斷框架比較
- Seata分布式事務
- 分布式事務問題
- Seata是什么
- Seata分布式事務過程
- Seata環境搭建
- 演示示例
- 業務說明
- 數據庫環境準備
- 微服務環境準備
- 測試
- Consul服務注冊與發現
- Consul是什么
- Consul能做什么
- 環境搭建
- Windows平臺
- 服務端入住Consul
- 消費端入住Consul
- 注冊中心對比
- Zookeeper服務注冊與發現
- Zookeeper是什么
- 環境搭建
- 服務端入住Zookeeper
- 消費端入住Zookeeper
- 網關服務Gateway
- Gateway是什么
- Gateway能做什么
- Gateway對比Zuul
- 三大核心概念
- Gateway工作流
- 環境搭建
- 網關路由配置方式
- 配置文件配置
- 代碼中配置
- 動態路由
- Predicate斷言
- 斷言是什么
- 常用斷言
- Filter過濾器
- 過濾器是什么
- 過濾器種類
- 自定義過濾器