Feign禁用Hystrix
1、完全禁用Hystrix
配置yml文件feign.hystrix.enabled=false
2、部分禁用Hystrix
2.1、FeignNoHystrixConfigure.java——编写Feign客户端配置类,重写feignBuilder方法
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope; import feign.Feign;
import feign.Retryer; //此配置类为了关闭特定Feign客户端的Hystrix支持
//注意:不要和服务启动类放在同一目录或子级目录下
@Configuration
public class FeignNoHystrixConfigure { // FeignClientsConfiguration 的默认配置如下
// Decoder feignDecoder: ResponseEntityDecoder (which wraps a SpringDecoder)
// Encoder feignEncoder: SpringEncoder
// Logger feignLogger: Slf4jLogger
// Contract feignContract: SpringMvcContract Feign.Builder
// feignBuilder: HystrixFeign.Builder Client
// feignClient: if Ribbon is enabled it is a LoadBalancerFeignClient, otherwise the default feign client is used. @Bean
@Scope("prototype")
public Feign.Builder feignBuilder(Retryer retryer) {
return Feign.builder();
} }
2.2、TestClient4.java——配置部分禁用Hystrix
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import com.mimaxueyuan.config.FeignNoHystrixConfigure; //关闭Hystrix(会导致所有的mima-cloud-producer都关闭,不管其它配置是否开启也会关闭,这是个坑要注意下)
@FeignClient(value="mima-cloud-producer",configuration=FeignNoHystrixConfigure.class)
public interface TestClient4 { @RequestMapping(value="/get/{id}",method=RequestMethod.GET)
public String get(@PathVariable("id") String id); }
Feign禁用Hystrix的更多相关文章
- SpringCloud系列十六:Feign使用Hystrix
1. 回顾 上文讲解了使用注解@HystrixCommand的fallbackMethod属性实现回退.然而,Feign是以接口形式工作的, 它没有方法体,前文讲解的方式显然不适用与Feign. 事实 ...
- Spring Cloud中,如何解决Feign整合Hystrix第一次请求失败的问题
Spring Cloud中,Feign和Ribbon在整合了Hystrix后,可能会出现首次调用失败的问题,要如何解决该问题呢? 造成该问题的原因 Hystrix默认的超时时间是1秒,如果超过这个时间 ...
- 0503-Hystrix保护应用-feign的hystrix支持
一.概述 1.1.基础[示例一] 如果Hystrix在类路径上并且feign.hystrix.enabled = true,Feign将用断路器包装所有方法.还可以返回com.netflix.hyst ...
- 在dropwizard中使用feign,使用hystrix
前言 用惯了spring全家桶之后,试试dropwizard的Hello World也别有一帆风味.为了增强对外访问API的能力,需要引入open feign.这里简单在dropwizard中使用fe ...
- SpringCloud Feign对Hystrix(断路由)的支持
第一步:首先开启Feign对Hystrix的支持,在properties文件中添加以下配置: feign.hystrix.enabled=true. 第二步:在上一篇Feign的基础上添加Hystri ...
- Feign 与 Hystrix
Feign 与 Hystrix Feign是一个声明式的web服务客户端,它使得web服务调用非常的简单,当我们使用Feign时,Spring Cloud 整合了Ribbon和Eureka,从而为我们 ...
- Feign使用Hystrix
Feign使用Hystrix开发步骤 1.导入依赖spring-cloud-starter-hystrix 2.消费启动类开启@EnableCircuitBreaker 3.配置yml文件feign. ...
- spring cloud: Hystrix(四):feign类似于hystrix的断容器功能:fallback
spring cloud: Hystrix(四):feign使用hystrix @FeignClient支持回退的概念:fallback方法,这里有点类似于:@HystrixCommand(fallb ...
- Spring Cloud(Dalston.SR5)--Feign 与 Hystrix 断路器整合
创建项目 要使 Feign 与 Hystrix 进行整合,我们需要增加 Feign 和 Hystrix 的依赖,修改 POM.xml 中增加以下依赖项如下: <?xmlversion=" ...
随机推荐
- vue-computed计算属性
计算属性:用来封装你想对一个属性进行的操作 computed VS mothod实现的效果和定义一个methods中的function相同,但是他们的区别在于:methods的function当触发重 ...
- playframework 一步一步来 之 日志 (二)
带着之前的疑问,我们先回顾一下日志相关的知识: 首先是SL4J,SL4J是个什么东西来着?官方解释为:“The Simple Logging Facade for Java (SLF4J) serve ...
- Java:ConcurrentHashMap
ConcurrentHashMap的目的 多线程环境下,使用Hashmap进行put操作会引起死循环,导致CPU利用率接近100%,所以在并发情况下不能使用HashMap.虽然已经有一个线程安全的Ha ...
- 渗透测试的理论部分2——OSSTMM的详细描述
昨天休息了一天,今天我要连更两篇博客,作为补充,以下为正文 本章详细描述了OSSTMM内的RAV得分这一理论概念,对日后从事正规安全工作至关重要 OSSTMM为开源安全测试方法论,对OSSTMM不了解 ...
- ABP框架系列之十一:(AspNet-Core-ASPNET核心)
Introduction This document describes ASP.NET Core integration for ASP.NET Boilerplate framework. ASP ...
- C++基础笔记(string截取)
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv ...
- STM32外设初始化步骤
1.定义外设结构体: 2.开启外设时钟: 3.调用缺省值配置函数: 4.外设具体配置: 5.外设使能.
- 26、TCP服务器原理
TCP / IP的工作 TCP / IP是Internet上使用的网络协议.它是协议,ESP32本身自带了TCP/IP协议,所以,我们只需了解并学会运用即可. 首先,有IP地址.这是一个32位值,应该 ...
- array_filter()函数
用回调函数过滤数组中的值 array_filter(array,callbackfunction); 返回过滤后的数组
- Tomcat 多项目部署方法整理
Tomcat 多项目部署方法整理 说明:tomcat-deploy-aaa和tomcat-deploy-bbb是两个不同的web项目,为了方便以下简称aaa和bbb,请先自行创建并跑通 导航: NO1 ...