SpringCloud - Spring Cloud Netflix 之 Hystrix ;turbine(十)

阅读本文前可先参考

SpringCloud - Spring Cloud根/父项目,开发准备(二)
https://blog.csdn.net/MinggeQingchun/article/details/125308948

https://blog.csdn.net/MinggeQingchun/article/details/125312594 

https://blog.csdn.net/MinggeQingchun/article/details/125315839

Spring Cloud Hystrix Turbine

Hystrix Dashboard 的主要功能是可以对某一项微服务进行监控,但真实情况下,不可能只对一个微服务进行监控,我们有很多微服务,所以我们需要对很多微服务进行监控,这个时候就需要使用到turbine [ˈtɜːbaɪn] 来完成

Hystrix Dashboard 前面已经知道了,它的主要功能是可以对某一项微服务进行监控,但真实情况下,不可能只对一个微服务进行监控,我们有很多微服务,所以我们需要对很多微服务进行监控,这个时候就需要使用到turbine [ˈtɜːbaɪn] 来完成

单个hystrix服务的监控

多个hystrix服务的监控

1、新建一个springboot Module(springcloud-6-service-eureka-hystrix-turbine),设置父项目

2、添加 spring-cloud-starter-netflix-turbine等 依赖

<dependencies>
        <!-- spring-cloud-starter-netflix-turbine -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
        </dependency>
    </dependencies>
<!--继承统一的父项目-->
    <parent>
        <groupId>com.company</groupId>
        <artifactId>springcloud-demo</artifactId>
        <version>1.0.0</version>
        <!--        <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;-->
    </parent>

    <groupId>com.company</groupId>
    <artifactId>springcloud-6-service-eureka-hystrix-turbine</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>springcloud-6-service-eureka-hystrix-turbine</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- spring-cloud-starter-netflix-turbine -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

3、application.prperties配置文件中配置访问端口3722

server.port=3722

#不向注册中心注册自己
eureka.client.register-with-eureka=false

#注册中心的链接地址  http://localhost:8761/eureka
eureka.client.service-url.defaultZone=http://eureka8761:8761/eureka,http://eureka8762:8762/eureka,http://eureka8763:8763/eureka

#配置turbine
turbine.app-config=springcloud-6-service-eureka-hystrix-consumer8081,springcloud-6-service-eureka-hystrix-consumer8082
#需要有这个,没有的话聚合不了多个项目
turbine.cluster-name-expression="default"

4、在 Spring Boot 的启动类中,添加@EnableTurbine 注解,//开启turbine对hystrix聚合汇总支持

@EnableTurbine //开启turbine对hystrix聚合汇总支持
@SpringBootApplication
public class EurekaHystrix6TurbineApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaHystrix6TurbineApplication.class, args);
    }

}

5、创建两个服务消费者 springcloud-6-service-eureka-hystrix-consumer8081,springcloud-6-service-eureka-hystrix-consumer8082(复制自springcloud-6-service-eureka-hystrix-consumer)

6、启动springboot启动类,访问应用,再去查看 DashBoard 控制中心控制台服务

http://localhost:8080/springcloud/eureka/hystrix/goodHystrixList

http://localhost:8081/springcloud/eureka/hystrix/goodHystrixList

http://localhost:8080/actuator/hystrix.stream

http://localhost:8081/actuator/hystrix.stream

http://localhost:3722/turbine.stream

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值