spring-cloud中运用ribbon和hytrix,在hystrix中使用turbine和Dashboard

本文介绍了在Spring Cloud中如何使用Ribbon进行微服务间的负载均衡,利用Hystrix实现服务容错,并通过Turbine聚合多个Hystrix流以监控服务状态。同时展示了如何配置和使用Hystrix Dashboard进行实时监控。当目标微服务不可用时,Hystrix提供回退机制避免雪崩效应。
摘要由CSDN通过智能技术生成

在学习中总会遇到很多问题,本例子可做参考用。

在微服务中的ribbon用于访问其它微服务中的节点,而hystrix用于在访问其它微服务的节点失败时所返回的信息,当访问的那个微服务挂掉了,或超时了,就会走@HystrixCommand(fallbackMethod = "fallbackIndex")中所指定的方法来反馈给用户,也能防止级联效应或雪崩效应。

在学习的过程中需要用到的jar:

<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		</dependency>

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

<dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>

首先是在启动类上配置必要的信息和需要用到的标签:

@SpringBootApplication
@EnableDiscoveryClient 
@Ribbo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值