前提是你已經有了注冊中心,然后搭建一個基礎spring cloud 服務,并配置注冊服務等等前提環境搭建
接下來描述的服務提供者和服務調用者的配置都是一樣的,來自《spring cloud 與 docker微服務架構實戰》的讀后的個人總結.
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
|
接下來的操作才是關鍵
1,將注冊中心 服務提供者 服務調用者 都啟動
2.訪問服務提供者 ip:port/hystrix 如圖
3. 圖中總共有三個文本框,其中第一個文本框是必填的,填寫的是服務調用者的 ip:port/hystrix.stream,然后點擊monitor stream.
4. 注意,如果第一個文本框填寫的不正確會展示如下內容
5. 訪問服務調用者,當然,該服務調用者提供的接口需要調用服務提供者提供的接口的
6.這時候就能看到如下內容,就證明你成功了
訪問hystrix.stream
訪問該連接時,想要出現如下的情況
這個就要訪問服務提供者的 ip:port/hystrix.stream
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/qq_33547169/article/details/78961564