一 簡介 在Spring Cloud中,Zuul預設已經整合了hystrix,做一個簡單的實踐。 二 實戰 1 啟動eureka。 2 啟動使用者微服務。 3 啟動zuul 4 啟動Dashboard 5 通路 http://localhost:8040/microservice-provider-user/1,可獲得正常結果
6 通路 http://localhost:8040/hystrix.stream,可獲得Hystrix的監控資料。
7 通路 http://localhost:8030/hystrix,并在監控位址欄中輸入 http://localhost:8040/hystrix.stream,可得到如下圖表
由圖可知,Zuul的Hystrix的監控粒度是微服務,而不是某個API;同時也說明,所有經過Zuul的請求,都會被Hystrix保護起來。 8 關閉項目user,再次通路 http://localhost:8040/microservice-provider-user/1,将會看到頁面輸出類似下面的異常: