package com.example.demo;

import com.netflix.hystrix.HystrixCommand;
//import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandProperties; import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.Target;
import feign.hystrix.HystrixFeign;
import feign.hystrix.SetterFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope; import java.lang.reflect.Method; @Configuration
@ConditionalOnClass({ HystrixCommand.class, HystrixFeign.class })
public class FeginConfiguration {
public static int connectTimeOutMillis = 5000;//超时时间
public static int readTimeOutMillis = 5000;
@Bean
public Request.Options options() {
return new Request.Options(connectTimeOutMillis, readTimeOutMillis);
} //自定义重试次数
@Bean
public Retryer feignRetryer(){
Retryer retryer = new Retryer.Default(100, 1000, 4);
return retryer;
} //hystrix 超时时间
@Bean
public Feign.Builder feignHystrixBuilder() {
return HystrixFeign.builder().setterFactory(new SetterFactory() {
@Override
public HystrixCommand.Setter create(Target<?> target, Method method) {
return HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(SchedualServiceHi.class.getSimpleName()))// 控制 RemoteProductService 下,所有方法的Hystrix Configuration
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(10000) // 超时配置
);
}
});
} }

feginclinet中设置hystrix的参数的更多相关文章

  1. Golang中设置函数默认参数的优雅实现

    在Golang中,我们经常碰到要设置一个函数的默认值,或者说我定义了参数值,但是又不想传递值,这个在python或php一类的语言中很好实现,但Golang中好像这种方法又不行.今天在看Grpc源码时 ...

  2. 在IDEA中设置命令行参数

  3. Direcshow中视频捕捉和参数设置报告

    Direcshow中视频捕捉和参数设置报告 1.      关于视频捕捉(About Video Capture in Dshow) 1视频捕捉Graph的构建 一个能够捕捉音频或者视频的graph图 ...

  4. 转:在Eclipse的Debug页签中设置虚拟机参数

    http://blog.csdn.net/decorator2015/article/details/50914479 在Eclipse的Debug页签中设置虚拟机参数 步骤 1,Run->De ...

  5. Jquery如何序列化form表单数据为JSON对象 C# ADO.NET中设置Like模糊查询的参数 从客户端出现小于等于公式符号引发检测到有潜在危险的Request.Form 值 jquery调用iframe里面的方法 Js根据Ip地址自动判断是哪个城市 【我们一起写框架】MVVM的WPF框架(三)—数据控件 设计模式之简单工厂模式(C#语言描述)

    jquery提供的serialize方法能够实现. $("#searchForm").serialize();但是,观察输出的信息,发现serialize()方法做的是将表单中的数 ...

  6. x264中重要结构体参数解释,参数设置,函数说明 <转>

    x264中重要结构体参数解释http://www.usr.cc/thread-51995-1-3.htmlx264参数设置http://www.usr.cc/thread-51996-1-3.html ...

  7. pg中与超时设置有关的参数

    statement_timeout控制语句执行时长,单位是ms.超过设定值,该语句将被中止.不推荐在postgresql.conf中设置,因为会影响所有的会话,如非要设置,应该设置一个较大值. loc ...

  8. 读取web.xml中设置的参数

    以获取Filer元素里设置的参数为例 先在web.xml文件中配置如下 <?xml version="1.0" encoding="UTF-8"?> ...

  9. 【记录一个问题】opencl enqueueWriteBuffer()中,cl_bool blocking参数设置无效

    err = queue.enqueueWriteBuffer(in_buf, true, 0, bmp_size, bmp_data, NULL, &event); 以上代码中,第二个参数设置 ...

随机推荐

  1. H5实现的手机摇一摇

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  2. Nginx随笔

    1.用于代理与反代理,处理大量请求的工具. 2.主要有三大模块:handle.upstream.过滤模块.handle用于在nginx内部接到请求并进行处理的状况:upstream用于需要nginx接 ...

  3. eclipse Java代码折叠工具

      eclipse Java代码折叠工具 CreateTime--2018年5月17日15点09分 Author:Marydon 1.问题描述 eclipse自带的代码折叠工具,无法折叠try{}ca ...

  4. idea 设置黑色背景

      idea 设置黑色背景 CreateTime--2018年4月26日10:32:38 Author:Marydon 设置-->Appearance-->Theme调为:Darcula- ...

  5. oracle 11g完美卸载

      oracle 11g完美卸载 CreateTime--2018年4月22日17:07:19 Author:Marydon 对于oracle数据库的卸载,一定要卸载干净,否则,再次想装oracle时 ...

  6. [Done]mysql in (#{list}) 只能查询/删除第一条的问题

    数据如下(注意age是int类型): sql如下(注意是#不是$): java代码: Mybatis日志(只返回一笔记录): 直接在mysql中执行(age是int类型,注意参数带引号,确认jdbc是 ...

  7. Redis学习(1)--环境配置,安装JDK,MySQL,tomcat

    Linux上安装jdk,mysql,tomcat安装 rpm命令: 相当于Windows的安装/卸载程序.可以进行程序的安装,更新,卸载,查看. 本地程序安装:rpm -ivh 程序名 本地程序查看: ...

  8. 获取泛型类对应的class类型

    自己写来备忘的,如有错误,请指正! public class Demo<T> { private Class<T> clazz; public Demo() { Paramet ...

  9. jsp中获取当前项目名称

    在JSP页面获取当前项目名称的方法: 方法1: <%= this.getServletContext().getContextPath() %> 方法2: 使用EL表达式 ${pageCo ...

  10. 调试解决iOS内存泄漏

    这里讲述在没有ARC的情况下,如何使用Instruments来查找程序中的内存泄露,以及NSZombieEnabled设置的使用. 本文假设你已经比较熟悉Obj-C的内存管理机制. 实验的开发环境:X ...