完善熔断、监控
diff --git a/samples/client/pom.xml b/samples/client/pom.xml
index a13d23a..5bc48d9 100644
--- a/samples/client/pom.xml
+++ b/samples/client/pom.xml
@@ -21,10 +21,10 @@
</dependency>
<!-- 微服务 健康监控 -->
- <!-- <dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
- </dependency> -->
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -32,7 +32,7 @@
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>com.supwisdom.infras</groupId>
<artifactId>infras-mvc</artifactId>
</dependency>
@@ -47,7 +47,6 @@
<artifactId>infras-i18n</artifactId>
</dependency>
- <!--
<dependency>
<groupId>com.supwisdom.infras</groupId>
<artifactId>infras-lang</artifactId>
@@ -96,6 +95,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
+ </dependency>
<!-- Test things -->
diff --git a/samples/client/src/main/java/com/supwisdom/leaveschool/client/ClientApplication.java b/samples/client/src/main/java/com/supwisdom/leaveschool/client/ClientApplication.java
index b09fe05..54b83cc 100644
--- a/samples/client/src/main/java/com/supwisdom/leaveschool/client/ClientApplication.java
+++ b/samples/client/src/main/java/com/supwisdom/leaveschool/client/ClientApplication.java
@@ -2,16 +2,35 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
+import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Bean;
+
+import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
@SpringBootApplication
@EnableCircuitBreaker
-@EnableFeignClients
+@EnableFeignClients(value = "com.supwisdom.leaveschool.client.service")
+@EnableHystrixDashboard
public class ClientApplication {
public static void main(String[] args) {
SpringApplication.run(ClientApplication.class, args);
}
+
+
+ @Bean
+ public ServletRegistrationBean<HystrixMetricsStreamServlet> hystrixMetricsStreamServlet() {
+ HystrixMetricsStreamServlet hystrixMetricsStreamServlet = new HystrixMetricsStreamServlet();
+
+ ServletRegistrationBean<HystrixMetricsStreamServlet> servletRegistrationBean = new ServletRegistrationBean<HystrixMetricsStreamServlet>(hystrixMetricsStreamServlet);
+ servletRegistrationBean.setName("hystrixMetricsStreamServlet");
+ servletRegistrationBean.setLoadOnStartup(1);
+ servletRegistrationBean.addUrlMappings("/hystrix.stream");
+
+ return servletRegistrationBean;
+ }
}
diff --git a/samples/client/src/main/resources/application.yml b/samples/client/src/main/resources/application.yml
index 550499b..9c58458 100755
--- a/samples/client/src/main/resources/application.yml
+++ b/samples/client/src/main/resources/application.yml
@@ -20,8 +20,8 @@
client:
config:
default:
- connectTimeout: 60000
- readTimeout: 60000
+ connectTimeout: 5000
+ readTimeout: 5000
loggerLevel: full
hystrix:
enabled: true
@@ -34,6 +34,6 @@
enabled: true
isolation:
thread:
- timeoutInMilliseconds: 60000
+ timeoutInMilliseconds: 5000
gateway.api.url: http://localhost:5555/api