Hystrix基本使用
来源:互联网 发布:百度旅游预测数据 编辑:程序博客网 时间:2024/06/07 07:04
0,User Guid
https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica#fallback
1,需要AOP引入
import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* HystrixCommandAop
* Created by jinglongjun on 16/9/19.
*/
@Configuration
@EnableAspectJAutoProxy
public class HystrixCommandAop {
@Bean
public HystrixCommandAspect hystrixAspect() {
return new HystrixCommandAspect();
}
}
2,需要在外部调用方法加入注解
@HystrixCommand(commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
}, fallbackMethod = "defaultCountOfTaobao")
public TradeCount countOfTaobao(User user, TradeCount tc, Boolean isBindUser) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
注意此方法必须是外部调用,如果是内部调用,则会导致方法无效。因为是通过命令模式的切面进入的,service内部methoda调用methodb无法对methodb加入切片.
3,配置说明
@HystrixCommand(groupKey="UserGroup", commandKey = "GetUserByIdCommand",
commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "500")
},
threadPoolProperties = {
@HystrixProperty(name = "coreSize", value = "30"),
@HystrixProperty(name = "maxQueueSize", value = "101"),
@HystrixProperty(name = "keepAliveTimeMinutes", value = "2"),
@HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"),
@HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440")
})
0 0
- Hystrix基本使用
- Hystrix使用
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- 学习使用Hystrix
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix 使用与分析
- Hystrix使用介绍
- shell编程(1)
- RPM命令
- Java继承
- virtualbox出现failed to attach usb,VERR_PDM_NO_USB_PORTS问题解决
- C#通过反射来动态创建类对象并调用相关泛型函数(Excel数据自动导入到SQL Server数据库)
- Hystrix基本使用
- 久病成医---PHP
- Oracle 笔记
- java定时器的使用(Timer)
- Java抽象类和接口
- 爱就投项目上线评审标准曝光
- Spark2.0在本地运行时报错URISyntaxException: Relative path in absolute URI: file:G:/code/VersionTest/spark-wa
- Android 获取系统的震动功能
- 十五章上机练习2