我是靠谱客的博主 紧张口红,这篇文章主要介绍Spring Cloud-hystrix Dashboard(八) 单机模式Turbine集群模式整合MQ,现在分享给大家,希望可以做个参考。

 

单机模式

1.创建一个dashboard项目

2.引入依赖

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!--histrix依赖--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency> <!--dashboard依赖--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency> <!--端点依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

3.在主类上打上注解@EnableHystrixDashboard开启dashboard

复制代码
1
2
3
4
5
6
7
@SpringBootApplication @EnableHystrixDashboard public class SpringCloudDashboardApplication { public static void main(String[] args) { SpringApplication.run(SpringCloudDashboardApplication.class, args); } }

4.配置文件配置应用名字和端口

复制代码
1
2
3
4
5
spring: application: name: hystrix-dashboard server: port: 2001

5.启动访问http://127.0.0.1:2001/hystrix

6.在consumer增加hystirx端点的Servlet

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/** * 用于开启histrix 端点 用于dashboard图形化 */ @Configuration public class HystrixStreamServletConfig { @Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/actuator/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; } }

7.访问http://127.0.0.1:9001/actuator/hystrix.stream  出现以下内容表示成功 将连接粘贴到仪表盘 开启分析

8.将连接粘贴到仪表盘 开启监控和分析

9.访问一个hystrix请求将会出现监控页面

Turbine集群模式

1.创建一个Turbine项目

2.添加依赖

复制代码
1
2
3
4
5
6
<!--&lt;!&ndash;实现hystrix集群监控依赖&ndash;&gt;--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> <version>2.0.1.RELEASE</version> </dependency>

3.开启turbine自动化配置和注册中心服务发现的功能 turbine里面依赖eurekaClient

复制代码
1
2
3
4
5
6
7
8
SpringBootApplication @EnableTurbine//启用turbine @EnableDiscoveryClient //开启服务发现 public class SpringCloudTurbineApplication { public static void main(String[] args) { SpringApplication.run(SpringCloudTurbineApplication.class, args); } }

4.配置文件配置

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
spring: application: name: trubine #http://localhost:9090/turbine.stream server: port: 9090 eureka: client: serviceUrl: defaultZone: http://peer1:1111/eureka,http://localhost:peer2/eureka turbine: app-config: consumer #监控的服务名 多个,号隔开 cluster-name-expression: new String('default') #指定集群的名称为default 当服务非常多turbine可以启动多个turbine构建集群 具体书194页 combine-host-port: true #可以通过主机名和端口名组合来进行区分

5.打包2个consumer并启动

 

6.在hystirx仪表盘配置监听trubine连接http://localhost:9090/turbine.stream

基于消息代理 

整合MQ

测试失败

转载于:https://www.cnblogs.com/LQBlog/p/10142956.html

最后

以上就是紧张口红最近收集整理的关于Spring Cloud-hystrix Dashboard(八) 单机模式Turbine集群模式整合MQ的全部内容,更多相关Spring内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(70)

评论列表共有 0 条评论

立即
投稿
返回
顶部