前言:

必需学会SpringBoot基础知识

简介:

spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理、服务发现、断路器、路由、微代理、事件总线、全局锁、决策竞选、分布式会话等等。它运行环境简单,可以在开发人员的电脑上跑。

工具:

JDK8

apache-maven-3.5.2

IntelliJ IDEA 2017.3 x64

一、Hystrix Turbine简介

看单个的Hystrix Dashboard的数据并没有什么多大的价值,要想看这个系统的Hystrix Dashboard数据就需要用到Hystrix Turbine。Hystrix Turbine将每个服务Hystrix Dashboard数据进行了整合。Hystrix Turbine的使用非常简单,只需要引入相应的依赖和加上注解和配置就可以了。

二、准备工作

本文使用的工程为上一篇文章的工程,在此基础上进行改造。需要添加两个服务项目, 本章节共需要四个项目, 3 and 4 是追加的

  1. eureka-server-hystrix-dashboard
  2. eureka-client-hystrix-dashboard
  3. eureka-client-hystrix-dashboard2 (仿照 2 改造*yml,需要修改名称加载顺序)
  4. eureka-client-hystrix-turbine

三、创建 eureka-client-hystrix-turbine

引入相应的依赖:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.lwc</groupId>
<artifactId>eureka-client-hystrix-turbine</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>eureka-client-hystrix-turbine</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.SR2</spring-cloud.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> <repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories> </project>

配置文件application.yml:

spring:
application.name: eureka-client-hystrix-turbine
server:
port: 8769
security.basic.enabled: false
turbine:
aggregator:
clusterConfig: default
appConfig: eureka-client-hystrix-dashboard,eureka-client-hystrix-dashboard2
clusterNameExpression: new String("default")
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/

配置文件, 具体我也是看百度在修改. 其实也无什么, 看API也有!

四、Turbine演示

依次开启工程:

  1. eureka-server-hystrix-dashboard
  2. eureka-client-hystrix-dashboard
  3. eureka-client-hystrix-dashboard2
  4. eureka-client-hystrix-turbine

打开浏览器输入: http://localhost:8761/ 查看注册中心界面如下:

打开浏览器输入:http://localhost:8769/turbine.stream,界面如下:

请求 (如果不依次, 你可能会感觉出问题, 因为WEB无数据)

http://localhost:8762/eureka/client?name=eddie

http://localhost:8763/eureka/client?name=eddie

打开:http://localhost:8763/hystrix,输入监控流http://localhost:8769/turbine.stream

点击monitor stream 进入页面:

可以看到这个页面聚合了2个service的hystrix dashbord数据。

提醒: 如果WEB UI 没有数据, 建议你把全部服务重启在试试!

五、源码下载:

标签 12-1

https://github.com/eddie-code/SpringCloudDemo

最新文章

  1. POJ 1321 DFS
  2. iOS拍照上传后,在web端显示旋转 Swift+OC版解决方案
  3. iOS webView 远程html加载本地资源
  4. Maven实战
  5. 微软职位内部推荐-Senior Software Engineer-Office Incubation
  6. LR之配置端口映射(port mapping)
  7. Google Chrome浏览器调试功能介绍
  8. A Very Easy Triangle Counting Game
  9. Javascript标准类型的方法集
  10. Js调用exe程序方法(通过URL Protocol实现网页调用本地应用程序)
  11. layui动态设置下拉框数据,根据后台数据设置选中
  12. [转] 如何设置双网卡同时连接内网外网_bpao_新浪博客
  13. Java+Selenium向文本框输入内容以后模仿键盘的&quot;ENTRY&quot;
  14. C Mergeable Stack(list超好用)
  15. HashMap源码之常用方法--JDK1.8
  16. 47_并发编程-线程python实现
  17. Editplus 竖选,竖插入技巧
  18. Git:创建远程仓库并推送内容到远程库
  19. PAT甲级 1127. ZigZagging on a Tree (30)
  20. OSX10.12搭建IPv6本地环境测试APP

热门文章

  1. yii2视频教材
  2. 记2019年目标之一没有996的大数据分析BI实战历程
  3. XML的序列化用法 vs平台开发
  4. es6解构赋值的几个用法
  5. JSON在Java中的使用(一)
  6. Windows 安装 MySQL 8.0.11
  7. CentOS 7紧急救援模式修改root用户密码的方法
  8. md5,md2加密加盐
  9. thinkPHP写txt日志文件
  10. Delphi 调试连接 任意Android手机/平板/盒子