首页 > 其他 > 详细

hystrix 添加turbine

时间:2020-12-16 09:37:57      阅读:41      评论:0      收藏:0      [点我收藏+]

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

hystrix 添加turbine

原文:https://www.cnblogs.com/hardy-wang/p/14142020.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!