Hystrix-超时设置
由于客户端请求服务端方法时,服务端方法响应超过1秒将会触发降级,所以我们可以配置Hystrix默认的超时配置
如果我们没有配置默认的超时时间,Hystrix将取default_executionTimeoutInMilliseconds作为默认超时时间
this.executionTimeoutInMilliseconds = getProperty(propertyPrefix, key, "execution.isolation.thread.timeoutInMilliseconds", builder.getExecutionIsolationThreadTimeoutInMilliseconds(), default_executionTimeoutInMilliseconds)
1.代码中修改默认超时配置(改为3秒):
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "3000")
})
public String serverMethod() {
return null;
}
2.application.properties中设置默认超时时间:
1.默认:(方法上记得要加上@HystrixCommand,否则无效):
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=3000 2.配置具体方法的超时时间
hystrix.command.serverMethod.execution.isolation.thread.timeoutInMilliseconds=3000
3.启动类:

package com.wangfajun; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; //@SpringBootApplication
//@EnableDiscoveryClient
//@EnableCircuitBreaker //开启断路器
@SpringCloudApplication
public class FajunClientTestApplication { public static void main(String[] args) {
SpringApplication.run(FajunClientTestApplication.class, args);
}
}

4.pom:
<!--hystrix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
Hystrix-超时设置的更多相关文章
- Hystrix超时测试
package com.cookie.test; import com.netflix.hystrix.HystrixCommand; import com.netflix.hystrix.Hystr ...
- delphi tidhttp 超时设置无效的解决方法
现在delphi都发布到xe8了,tidhttp还有缺陷,那就是超时设置在没有网络或者连不上服务器的时候是无效的,不管你设置为多少都要10-20秒.connectTimeout和readTimeout ...
- Linux串口中的超时设置
在Linux下使用串口通信时,默认的阻塞模式是不实用的.而采用select或epoll机制的非阻塞模式,写代码有比较麻烦.幸好Linux的串口自己就带有超时机制. Linux下使用termios.h中 ...
- org.apache.http.client.HttpClient; HttpClient 4.3超时设置
可用的code import org.apache.commons.lang.StringUtils;import org.apache.http.HttpEntity;import org.apac ...
- HttpClient 3.X 4.3 4.x超时设置
HttpClient 4.3.HttpClient这货和Lucene一样,每个版本的API都变化很大,这有点让人头疼.就好比创建一个HttpClient对象吧,每一个版本的都不一样, 3.X是这样的 ...
- Apache性能优化、超时设置,linux 重启apache
在httpd.conf中去掉Include conf/extra/httpd-default.conf前的#以使httpd-default.php生效.其中调节以下参数Timeout 15 (连接超时 ...
- libcurl多线程超时设置不安全(转)
from http://www.cnblogs.com/kex1n/p/4135263.html (1), 超时(timeout) libcurl 是 一个很不错的库,支持http,ftp等很多的协议 ...
- CXF超时设置
转自: http://peak.iteye.com/blog/1285211 http://win.sy.blog.163.com/blog/static/9419718620131014385644 ...
- 使用select io复用实现超时设置
在linux的socket编程中,经常会遇到超时设置的问题,例如请求方如果在Ks内不发送数据则服务器要断开连接停止服务.这里我使用select的io复用实现超时5s设置,具体代码片段如下: fd_se ...
- jquery ajax超时设置
var ajaxTimeoutTest = $.ajax({ url:'', //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'get', //请求方式 ...
随机推荐
- JSP指令include和JSP动作元素include的区别
include指令用于在JSP页面静态的包含一个文件,该文件可以是JSP页面.HTML页面.文本文件或者一段java代码.使用include指令的JSP页面在转换时,JSP容器会在其中插入所包含文件的 ...
- opencv mat flags含义
f:\opencv\opencv\sources\modules\core\src\matrix.cpp: flags = (_type & CV_MAT_TYPE_MASK) | MAGI ...
- windows server 2008 修改域的密码策略
1.一般情况下,进入本地安全策略修改密码策略时,,密码策略已经被锁定,无法更改,若要修改域服务器上的密码策略,请按照步骤2--6进行修改 2.在此情况下要改密码策略的过程如下, 进入组策略管理: 3. ...
- win7 X64 使用VS2008 ->编译报错LINK : fatal error LNK1000: Internal error during Incr的解决
编译报错LINK : fatal error LNK1000: Internal error during Incr的解决 Win7 旗舰版 Microsoft Visual Studio 2008 ...
- Oracle学习操作(6)函数与存储过程
一.oracle自定义函数 1.不带参数的函数: 返回t_book表的总条数: SQL> create function getBookCount return number as begin ...
- HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot-报错解决方法
操作:jsp文件里面添加<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" % ...
- [转]Oracle 中计算时间间隔的SQL 语句
' second as TSec from dual -- 计算 60秒 前的时间 ' minute as TMin from dual -- 计算 10分 前的时间 ' hour as UTCTim ...
- centos7 防火墙一些相关设置 开机添加静态路由 特殊的方法
参考文献: https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/security_guide/s ...
- 基于nginx和tengine的tcp反向代理,负载均衡 安装和配置
先下载nginx_tcp_proxy_module模块. wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master ...
- oletools下载安装及rtfobj使用
rtf内嵌对象分析提取工具rtfobj是oletools的一部分 oletools各个版本下载地址https://bitbucket.org/decalage/oletools/downloads/ ...