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的更多相关文章

  1. SpringCloud系列十六:Feign使用Hystrix

    1. 回顾 上文讲解了使用注解@HystrixCommand的fallbackMethod属性实现回退.然而,Feign是以接口形式工作的, 它没有方法体,前文讲解的方式显然不适用与Feign. 事实 ...

  2. Spring Cloud中,如何解决Feign整合Hystrix第一次请求失败的问题

    Spring Cloud中,Feign和Ribbon在整合了Hystrix后,可能会出现首次调用失败的问题,要如何解决该问题呢? 造成该问题的原因 Hystrix默认的超时时间是1秒,如果超过这个时间 ...

  3. 0503-Hystrix保护应用-feign的hystrix支持

    一.概述 1.1.基础[示例一] 如果Hystrix在类路径上并且feign.hystrix.enabled = true,Feign将用断路器包装所有方法.还可以返回com.netflix.hyst ...

  4. 在dropwizard中使用feign,使用hystrix

    前言 用惯了spring全家桶之后,试试dropwizard的Hello World也别有一帆风味.为了增强对外访问API的能力,需要引入open feign.这里简单在dropwizard中使用fe ...

  5. SpringCloud Feign对Hystrix(断路由)的支持

    第一步:首先开启Feign对Hystrix的支持,在properties文件中添加以下配置: feign.hystrix.enabled=true. 第二步:在上一篇Feign的基础上添加Hystri ...

  6. Feign 与 Hystrix

    Feign 与 Hystrix Feign是一个声明式的web服务客户端,它使得web服务调用非常的简单,当我们使用Feign时,Spring Cloud 整合了Ribbon和Eureka,从而为我们 ...

  7. Feign使用Hystrix

    Feign使用Hystrix开发步骤 1.导入依赖spring-cloud-starter-hystrix 2.消费启动类开启@EnableCircuitBreaker 3.配置yml文件feign. ...

  8. spring cloud: Hystrix(四):feign类似于hystrix的断容器功能:fallback

    spring cloud: Hystrix(四):feign使用hystrix @FeignClient支持回退的概念:fallback方法,这里有点类似于:@HystrixCommand(fallb ...

  9. Spring Cloud(Dalston.SR5)--Feign 与 Hystrix 断路器整合

    创建项目 要使 Feign 与 Hystrix 进行整合,我们需要增加 Feign 和 Hystrix 的依赖,修改 POM.xml 中增加以下依赖项如下: <?xmlversion=" ...

随机推荐

  1. js 原型链与继承

    var A = function(){ this.name="xiaoming"; } A.prototype.age=9; var a = new A(); console.lo ...

  2. CSS的六大选择器

    选择器:选择器是一种模式,用于选择需要添加样式的元素. 首先简述六大选择器 基本选择器 标签选择器 类选择器 ID选择器 高级选择器 层次选择器 结构伪类选择器 属性选择器 其中基本选择器与层次选择器 ...

  3. day 7 编码

    menu = { '北京': { '朝阳': { '国贸': { 'CICC': {}, 'HP': {}, '渣打银行': {} }, '望京': { '陌陌': {}, '奔驰': {} } }, ...

  4. Spring MVC 上传和下载文件

    上传文件 Commons FileUpload 元件 Servlet 3.0 本地文件上传特性 HTML 5 下载文件

  5. using python read/write HBase data

    A. operations on Server side 1. ensure hadoop and hbase are working properly 2. install thrift:  apt ...

  6. 第40章:MongoDB-集群--Replica Sets(副本集)---副本集的管理

    ①以单机模式启动成员 由于很多维护的工作需要写入操作,所以不合适在副本集中操作,可以以单机模式启动成员,也就是不要使用副本的选项,就跟以前启动单独的服务器一样.一般使用一个跟副本集配置中不一样的端口号 ...

  7. 《Node.js 高级编程》简介与第二章笔记

    <Node.js 高级编程> 作者简介 Pedro Teixerra 高产,开源项目程序员 Node 社区活跃成员,Node公司的创始人之一. 10岁开始编程,Visual Basic.C ...

  8. Solutions and Summay for Linked List Naive and Easy Questions

    1.Remove Linked List Elements package linkedlist; /* * Question: Remove all elements from a linked l ...

  9. Log system architecture

    0. 技术选型参考 1. Collector Keywords: Collector, Processor 名称 Beats Fluentd-bit Introduction Beats are a ...

  10. 【leetcode】 算法题2 两数相加

      问题      给定两个非空链表来表示两个非负整数.位数按照逆序方式存储,它们的每个节点只存储单个数字.将两数相加返回一个新的链表. 你可以假设除了数字 0 之外,这两个数字都不会以零开头. 示例 ...