【问题标题】:how to config spring cloud hystrix semaphore max concurrent如何配置spring cloud hystrix semaphore max concurrent
【发布时间】:2016-01-10 16:52:21
【问题描述】:

并发测试失败,日志显示:

com.netflix.hystrix.exception.HystrixRuntimeException:community-serviceRibbonCommand 无法获取用于执行的信号量并且没有可用的回退。

我阅读了源代码。似乎是由 executionIsolationSemaphoreMaxConcurrentRequests 控制的。

我的问题是如何增加 executionIsolationSemaphoreMaxConcurrentRequests?

【问题讨论】:

  • execution.isolation.semaphore.maxConcurrentRequests 运气好吗?

标签: spring-cloud hystrix


【解决方案1】:

如果你使用 Setter,你可以

    public class HystrixCommandInstance extends HystrixCommand<>        
      public HystrixCommandInstance() {
          super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("SomeGroupName"))
          .andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
                 .withExecutionIsolationSemaphoreMaxConcurrentRequests(200)));
      }
   }

【讨论】:

    【解决方案2】:

    如果你使用@HystrixCommand注解,你可以指定commandProperties()来配置命令。

    @HystrixCommand(fallbackMethod = "fallbackMethod",
                commandProperties = {
                        @HystrixProperty(name = "execution.isolation.semaphore.maxConcurrentRequests", value = "15")
                 })
    

    【讨论】:

      猜你喜欢
      • 2016-12-12
      • 2016-03-31
      • 2018-02-23
      • 2016-06-18
      • 2015-05-31
      • 2018-07-21
      • 2016-06-30
      • 2016-12-08
      • 2018-07-18
      相关资源
      最近更新 更多