Hystrix-Dashboard-Turbine

参考文章:https://blog.csdn.net/trisonlu123/article/details/80100031

一、体验Hystrix-Dashboard

在consumer基础上进行更改

1、增加依赖

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2、修改Main类

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrixDashboard
@EnableCircuitBreaker
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }
}

3、案例

启动server,producer,consumer

访问http://localhost:8003/hystrix


点击Monitor Stream


具体看效果可以访问下接口,看下监控效果,再停掉producer服务,再访问下接口,再看监控效果

具体监控描述如下图


二、体验Turbine

1、Hystrix-dashboard-turbine

①依赖配置

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>1.5.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <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.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
    </dependencies>

②application.properties

spring.application.name=hystrix-dashboard-turbine

server.port=8003
turbine.appConfig=node01,node02
turbine.aggregator.clusterConfig= default
turbine.clusterNameExpression= new String("default")

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

③Main类

@SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class DashboardApplication {
    public static void main(String[] args) {
        SpringApplication.run(DashboardApplication.class, args);
    }
}

2、consumer-node1,由consumer修改而来

application.properties

spring.application.name=node01

server.port=8001

feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/
3、consumer-node2,由consumer修改而来

①application.properties

spring.application.name=node02

server.port=8002

feign.hystrix.enabled=true

eureka.client.serviceUrl.defaultZone=http://localhost:8000/eureka/

②DemoRemote.java

@FeignClient(name = "spring-cloud-producer2", fallback = DemoRemoteHystrix.class)
public interface DemoRemote {
    @RequestMapping(value = "/demo")
    public String demo2(@RequestParam(value = "message") String message);
}

同时修改DemoRemoteHystrix.java和DemoController.java

4、案例

同时启动服务、consumer-node1、consumer-node2、hystrix-dashboard-turbine

①访问http://localhost:8000/,发现三个注册方


②访问http://localhost:8003/turbine.stream


发现监控一直存在,不断的调出:ping

③访问http://localhost:8003/hystrix


点击Monitor Stream


发现同时监控了两个consumer


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值