ソースを参照

message-service 引入 spring-cloud-starter-netflix-hystrix-dashboard 和 spring-cloud-starter-netflix-turbine 依赖, 提供 Hystrix 监控面板和 Terbine 集群监控

reghao 8 ヶ月 前
コミット
34b0e6e0e2

+ 10 - 0
message/message-service/pom.xml

@@ -84,6 +84,16 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
+            <version>2.2.10.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
+            <version>2.2.10.RELEASE</version>
+        </dependency>
 
         <dependency>
             <groupId>org.dom4j</groupId>

+ 4 - 0
message/message-service/src/main/java/cn/reghao/tnb/message/app/MessageApplication.java

@@ -2,10 +2,14 @@ package cn.reghao.tnb.message.app;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
+import org.springframework.cloud.netflix.turbine.EnableTurbine;
 import org.springframework.context.annotation.ComponentScan;
 
 @SpringBootApplication
 @ComponentScan({"cn.reghao.tnb.common", "cn.reghao.tnb.message.app"})
+@EnableHystrixDashboard
+@EnableTurbine
 public class MessageApplication {
     public static void main(String[] args) {
         SpringApplication.run(MessageApplication.class, args);

+ 13 - 1
message/message-service/src/main/resources/application.yml

@@ -29,4 +29,16 @@ eureka:
     prefer-ip-address: true
   client:
     register-with-eureka: true
-    fetch-registry: true
+    fetch-registry: true
+hystrix:
+  dashboard:
+    proxy-stream-allow-list: "localhost"
+turbine:
+  # 需要收集信息的服务名,即注册中心服务名称
+  appConfig: user-service
+  aggregator:
+    cluster-config: default
+  # 指定集群名称
+  cluster-name-expression: new String("default")
+  # 同一主机上的服务通过主机名和端口号的组合来进行区分,默认以host来区分
+  combine-host-port: true