spring cloud:hystrix-dashboard-turbine

Posted alittlesmile

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

技术图片

 

以上是关于spring cloud:hystrix-dashboard-turbine的主要内容,如果未能解决你的问题,请参考以下文章

Spring全家桶笔记:Spring+Spring Boot+Spring Cloud+Spring MVC

学习笔记——Spring简介;Spring搭建步骤;Spring的特性;Spring中getBean三种方式;Spring中的标签

Spring--Spring入门

Spring框架--Spring事务管理和Spring事务传播行为

Spring框架--Spring事务管理和Spring事务传播行为

Spring框架--Spring JDBC