码迷,mamicode.com
首页 > 编程语言 > 详细

spring cloud:hystrix-dashboard-turbine

时间:2019-05-20 21:02:58      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:service   version   framework   web   lan   file   edit   其它   修改   

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

标签:service   version   framework   web   lan   file   edit   其它   修改   

原文地址:https://www.cnblogs.com/alittlesmile/p/10896203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!