前提是你已經(jīng)有了注冊中心,然后搭建一個基礎(chǔ)spring cloud 服務(wù),并配置注冊服務(wù)等等前提環(huán)境搭建
接下來描述的服務(wù)提供者和服務(wù)調(diào)用者的配置都是一樣的,來自《spring cloud 與 docker微服務(wù)架構(gòu)實(shí)戰(zhàn)》的讀后的個人總結(jié).
pom文件中需要引入spring-cloud-starter-hystrix/spring-cloud-starter-hystrix-dashboard/spring-cloud-netflix-hystrix-stream/spring-cloud-starter-turbine-stream/spring-cloud-starter-stream-rabbit
如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-hystrix</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-hystrix-dashboard</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-netflix-hystrix-stream</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-turbine-stream</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-stream-rabbit</artifactid> </dependency> |
啟動類需要添加如下注解
1
2
3
4
5
|
/*turibine監(jiān)控*/ @enableturbinestream @enablecircuitbreaker /*dashboard監(jiān)控*/ @enablehystrixdashboard |
接下來的操作才是關(guān)鍵
1,將注冊中心 服務(wù)提供者 服務(wù)調(diào)用者 都啟動
2.訪問服務(wù)提供者 ip:port/hystrix 如圖
3. 圖中總共有三個文本框,其中第一個文本框是必填的,填寫的是服務(wù)調(diào)用者的 ip:port/hystrix.stream,然后點(diǎn)擊monitor stream.
4. 注意,如果第一個文本框填寫的不正確會展示如下內(nèi)容
5. 訪問服務(wù)調(diào)用者,當(dāng)然,該服務(wù)調(diào)用者提供的接口需要調(diào)用服務(wù)提供者提供的接口的
6.這時候就能看到如下內(nèi)容,就證明你成功了
訪問hystrix.stream
訪問該連接時,想要出現(xiàn)如下的情況
這個就要訪問服務(wù)提供者的 ip:port/hystrix.stream
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/qq_33547169/article/details/78961564