zoukankan      html  css  js  c++  java
  • hystrix 添加turbine

    1.创建turbine项目,修改pom.xml文件

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</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-netflix-hystrix</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
            </dependency>
    

    2.创建main函数

    package com.imooc.springcloud;
    
    import org.springframework.boot.WebApplicationType;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
    import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
    import org.springframework.cloud.netflix.hystrix.EnableHystrix;
    import org.springframework.cloud.netflix.turbine.EnableTurbine;
    
    @EnableDiscoveryClient
    @EnableHystrix
    @EnableCircuitBreaker
    @EnableTurbine
    @EnableAutoConfiguration
    public class TurbineApplication {
        public static void main(String[] args) {
            new SpringApplicationBuilder(TurbineApplication.class)
                    .web(WebApplicationType.SERVLET)
                    .run(args);
        }
    }
    
    

    3.添加配置

    3.1修改turbine的application.propertise
    spring.application.name=hystrix-turbine
    server.port=52000
    management.port=52001
    
    eureka.client.serviceUrl.defaultZone=http://localhost:20000/eureka/
    
    # 指定了需要监控的服务名
    turbine.app-config=hystrix-consumer
    turbine.cluster-name-expression="default"
    
    # 将端口和hostname 作为区分不同服务的条件
    turbine.combine-host-port=true
    turbine.instanceUrlSuffix.default=actuator/hystrix.stream
    turbine.aggregator.clusterConfig=default
    

    3.2 在原来用hystrix的服务中配置文件中添加下面配置

    # actuator 暴露接口
    management.security.enabled=false
    management.endpoints.web.exposure.include=*
    management.endpoint.health.show-details=always
    

    4.开启Eureka,服务提供者,服务消费者

  • 相关阅读:
    wxpython笔记:应用骨架
    go 优雅的检查channel关闭
    Golang并发模型:流水线模型
    go http数据转发
    go 互斥锁与读写锁
    go 工作池配合消息队列
    实现Tcp服务器需要考虑哪些方面
    go Goroutine泄露
    关于个人博客转移的那些事
    Java并发编程:Thread类的使用介绍
  • 原文地址:https://www.cnblogs.com/hardy-wang/p/14142020.html
Copyright © 2011-2022 走看看