super(Setter
//设置GroupKey 用于dashboard 分组展示
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Semaphore4UserLotteryLimitingGroup"))
//设置commandKey 用户隔离线程池,不同的commandKey会使用不同的线程池
.andCommandKey(HystrixCommandKey.Factory.asKey("Semaphore4UserLotteryLimitingKey"))
//设置线程池名字的前缀,默认使用commandKey
.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey("Semaphore4UserLotteryLimitingThreadPoolKey"))
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter()
// 舱壁隔离策略:信号量隔离策略,通常不会用这个,除非是纯内存操作或者简单的并发控制
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
//设置每组command可以申请的permit最大数
//这个参数和线程池的核心线程数是同样的意义,允许有多少个请求同时请求资源。
.withExecutionIsolationSemaphoreMaxConcurrentRequests(0)
//fallback方法的信号量配置,配置getFallback方法并发请求的信号量,
// 如果请求超过了并发信号量限制,则不再尝试调用getFallback方法,而是快速失败,默认信号量为10
.withFallbackIsolationSemaphoreMaxConcurrentRequests(1)
//是否启用降级处理,如果启用了,则在超时或异常时调用getFallback进行降级处理,默认开启
.withFallbackEnabled(true)
//执行超时时间,默认为1000毫秒,如果命令是线程隔离,且配置了executionIsolationThreadInterruptOnTimeout=true,则执行线程将执行中断处理。
// 如果命令是信号量隔离,则进行终止操作,因为信号量隔离与主线程是在一个线程中执行,其不会中断线程处理
.withExecutionTimeoutInMilliseconds(2000)
//是否启用执行超时机制,默认为true
.withExecutionTimeoutEnabled(true)
//当隔离策略为THREAD时,当执行线程执行超时时,是否进行中断处理,默认为true
.withExecutionIsolationThreadInterruptOnTimeout(true)
)
//设置线程池相关参数,设置了信号量隔离后,线程池配置将变无效,因为信号量隔离策略是基于tomcat或者jetty容器线程做隔离
.andThreadPoolPropertiesDefaults(
HystrixThreadPoolProperties.Setter()
// 配置线程池里的线程数
.withCoreSize(13)
)
分享到:
相关推荐
hystrix
Hystrix源码_可以跑起来Hystrix源码_可以跑起来Hystrix源码_可以跑起来Hystrix源码_可以跑起来
netflix官方提供的监控hystrix-dashboard的war包,可以直接拷贝到web服务下运行,方便大家下载学习,该版本为1.5.12
Hystrix 熔断,降级
在公司内部做的一次分享,生产环境使用hystrix来进行调用dubbo服务的超时、熔断、重试、限流的Netflix框架
Hystrix是Netflix开源的一款容错框架,包含常用的容错方法:线程隔离、信号量隔离、降级策略、熔断技术。 在高并发访问下,系统所依赖的服务的稳定性对系统的影响非常大,依赖有很多不可控的因素,比如网络连接变慢...
详细讲解了如何在Spring Cloud中使用Hystrix,如何将Hystrix整合到Feign中
Hystrix-Dashboard使用 运行nohup java -jar standalone-hystrix-dashboard-1.5.6-all.jar & 浏览器打开http://localhost:7979/hystrix-dashboard/ 输入地址http://localhost/hystrix.stream 先点击 add stream ...
hystrix原理
HystrixCommand及配置实例,亲测可用,有参数配置说明
hystrix-serialization-1.5.18.jar
hystrix接入.docx
springcloud hystrix-dashboard
spring cloud hystrix &&dashboard源码解读
springcloud hystrix 断路由 http://knight-black-bob.iteye.com/blog/2356431
spring-cloud-netflix-hystrix应用
spring cloud hystrix通过服务隔离、熔断、降级等手段控制依赖服务的延迟与失败。
spring cloud eureka zuul ribbon hystrix feign config 示例代码
springcloud hystrix jar包,java -jar xx.jar,小熊界面
Spring Cloud Netfix Hystrix断路器例子工程。使用Spring Cloud Netflix Hystrix以及Spring RestTemplate或Spring Cloud Netflix Feign实现断路器模式。