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,服务提供者,服务消费者

  • 相关阅读:
    Oracle删除约束和主键的语句
    Tomcat启动时SecureRandom超级慢的问题
    MySQL innodb引擎下根据.frm和.ibd文件恢复表结构和数据
    ORA-00604: 递归 SQL 级别 1 出现错误 ORA-01653: 表 SYS.AUD$ 无法通过 8192 (在表空间 SYSTEM 中) 扩展
    Linux 使用pwgen命令创建随机密码
    nginx 之 proxy_pass详解
    给nginx生成自签名证书
    常见排序算法(java实现)
    浅析变量的作用域和生存周期的差别
    filter过滤器
  • 原文地址:https://www.cnblogs.com/hardy-wang/p/14142020.html
Copyright © 2011-2022 走看看