java B2B2C Springcloud多租户电子商城系统-断路器聚合监控
一、Hystrix Turbine简介
看单个的Hystrix Dashboard的数据并没有什么多大的价值,要想看这个系统的Hystrix Dashboard数据就需要用到Hystrix Turbine。Hystrix Turbine将每个服务Hystrix Dashboard数据进行了整合。Hystrix Turbine的使用非常简单,只需要引入相应的依赖和加上注解和配置就可以了。
二、准备工作
本文使用的工程为上一篇文章的工程,在此基础上进行改造。因为我们需要多个服务的Dashboard,所以需要再建一个服务,取名为service-lucy,它的基本配置同service-hi,具体见源码,在这里就不详细说明。
三、创建service-turbine
引入相应的依赖:
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <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> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-turbine</artifactId> </dependency> </dependencies>
在其入口类ServiceTurbineApplication加上注解@EnableTurbine,开启turbine,@EnableTurbine注解包含了@EnableDiscoveryClient注解,即开启了注册服务。
@SpringBootApplication @EnableEurekaClient @EnableDiscoveryClient @RestController @EnableHystrix @EnableHystrixDashboard @EnableCircuitBreaker @EnableTurbine public class ServiceTurbineApplication { /** * http://localhost:8764/turbine.stream */ public static void main(String[] args) { SpringApplication.run( ServiceTurbineApplication.class, args ); } }
配置文件application.yml:
spring: application.name: service-turbine server: port: 8769 security.basic.enabled: false turbine: aggregator: clusterConfig: default # 指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问 appConfig: service-hi,service-la ### 配置Eureka中的serviceId列表,表明监控哪些服务 clusterNameExpression: new String("default") # 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称 # 2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default # 3. 当clusterNameExpression: metadata['cluster']时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/
Turbine演示
依次开启server、service-hi、service-la、service-turbine工程。
打开浏览器输入:http://localhost:8769/turbine.stream,
依次请求:
http://localhost:8762/hi?name=whhttp://localhost:8763/hi?name=wh
打开:http://localhost:8763/hystrix,输入监控流http://localhost:8769/turbine.stream,点击monitor stream,可以看到这个页面聚合了2个service的hystrix dashbord数据。
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
小伙子用C语言写出绽放的玫瑰花,成功表白C++代码女神!
今天就给大家带来一个绝佳的礼物,用来跟妹子表白,让大家早点脱离单身汪的生活。 (感谢我吧,这可不容易哦~~~) 那么今天的神秘礼物是什么呢?大家猜猜送妹子什么最好呢? (送什么都不如送玫瑰花呀~~~)没错,今天给大家带来的就是一多缓慢绽放的玫瑰花!话不多说,先看图: 玫瑰花 初具雏形的玫瑰 绽放的玫瑰,送给可爱的XXX 看起来是不是挺不错的呢!大家是不是觉得就结束了呢? “当!然!不!是!”如果只有一朵花怎么能衬托出这中氛围呢?来首音乐才有情调嘛!然后我们再添加一首音乐!一边听着音乐,一边看着一朵玫瑰的绽放,是不是特有情调?(音乐不能截图,有需要的自己来找我吧)也许你就能从此告白成功,脱离单身,走向幸福的两人世界哦!(没成功当我没说(━┳━ _ ━┳━)) 好了下面来看下源码: 这就是程序的全部代码啦!如果想更换音乐只要改下你想要替换的音乐名字改为【音乐】就好了,当然了格式必须是MP3格式的才可以哦
- 下一篇
java B2B2C Springboot电子商城系统-高可用的服务注册中心
文章介绍了服务注册与发现,其中服务注册中心Eureka Server,是一个实例,当成千上万个服务向它注册的时候,它的负载是非常高的,这在生产环境上是不太合适的,这篇文章主要介绍怎么将Eureka Server集群化。 一、准备工作 Eureka can be made even more resilient and available by running multiple instances and asking them to register with each other. In fact, this is the default behaviour, so all you need to do to make it work is add a valid serviceUrl to a peer, e.g. 摘自官网 Eureka通过运行多个实例,使其更具有高可用性。事实上,这是它默认的熟性,你需要做的就是给对等的实例一个合法的关联serviceurl。 这篇文章我们基于第一篇文章的工程,来做修改。 二、改造工作 在eureka-server工程中resources文件夹下...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- CentOS7,CentOS8安装Elasticsearch6.8.6
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- Red5直播服务器,属于Java语言的直播服务器
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- Hadoop3单机部署,实现最简伪集群
- CentOS关闭SELinux安全模块