zoukankan      html  css  js  c++  java
  • spring cloud:hystrix-dashboard-turbine

    hystrix-dashboard-turbine-server

    1. File-->new spring starter project

    2.add dependency

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.5.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    <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>

    3.Edit application.yml

    server:
      port: 9000
    
    spring:
      application:
        name: hystrix-dashboard-turbine-server
    
    turbine:
      app-config: hystrix-dashboard-client-node1,hystrix-dashboard-client-node2
      aggregator:
        cluster-config: default
      cluster-name-expression: new String("default")
    eureka:
      client:
        service-url:
          defaultZone: http://localhost:8761/eureka/

    4.program

    package com.smile;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
    import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
    import org.springframework.cloud.netflix.turbine.EnableTurbine;
    
    @SpringBootApplication
    @EnableHystrixDashboard
    @EnableTurbine
    @EnableEurekaClient
    public class HystrixDashboardTurbineServerApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(HystrixDashboardTurbineServerApplication.class, args);
        }
    
    }

    5.Run

    http://localhost:9000/hystrix

    http://localhost:9000/turbine.stream  

    由于是默认cluster,所以输入 http://localhost:9000/turbine.stream,click Monitor Stream

    按照 hystrix-dashboard-client 分别创建 hystrix-dashboard-client-node1和 hystrix-dashboard-client-node2 修改如下

    server:
      port: 9002
    spring: application: name: hystrix
    -dashboard-client-node1
    server:
      port: 9003
    spring: application: name: hystrix-dashboard-client-node2
    package com.smile.remote;
    
    import org.springframework.cloud.openfeign.FeignClient;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    
    @FeignClient(name = "producer",fallback = HelloServiceHystrix.class)
    public interface HelloService {
        
        @RequestMapping("/getHello")
        public String getHello1(@RequestParam String name);
    }
    package com.smile.remote;
    
    import org.springframework.cloud.openfeign.FeignClient;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    
    @FeignClient(name = "producer",fallback = HelloServiceHystrix.class)
    public interface HelloService {
        
        @RequestMapping("/getHello")
        public String getHello2(@RequestParam String name);
    }

    将其它class中调用到getHello()的地方对应修改一下就可以了, 有时会出现监控不到的情况,需要请求以下该服务的actuator接口就可以了 such as: http://localhost:9003/actuator

    此处只有一个 Thread Pools ,because just one producer

  • 相关阅读:
    bzoj4196: [Noi2015]软件包管理器
    bzoj3992: [SDOI2015]序列统计
    bzoj 4178: A
    Spoj 8372 Triple Sums
    hdu contest day1 1007 Tricks Device
    hdu contest day1 1002 Assignment
    2018暑期生活指导第三周
    2018暑期生活指导第二周
    《大道至简》阅读笔记
    2018暑期生活指导第一周
  • 原文地址:https://www.cnblogs.com/alittlesmile/p/10896203.html
Copyright © 2011-2022 走看看