@HystricCommand未配置

时间:2017-10-24 16:59:12

标签: spring-boot hystrix spring-cloud-config

我在使用Spring Cloud Config配置的Spring Boot应用程序中的@HystrixCommand中使用@Component,而Hystrix命令未选择配置。

如果我使用Actuator env端点,我会看到我的Hystrix配置。

"hystrix.command.default.circuitBreaker.enabled": true,
"hystrix.command.default.circuitBreaker.requestVolumeThreshold": 20,
"hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds": 20000,
"hystrix.command.default.execution.isolation.strategy": "THREAD",
"hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds": 10000,
"hystrix.command.default.execution.timeout.enabled": true,
"hystrix.command.default.metrics.rollingStats.numBuckets": 200,
"hystrix.command.default.metrics.rollingStats.timeInMilliseconds": 10000,

如果我使用archaius端点,我什么都看不见。

{}

我可以在后备中看到使用以下配置。它确认我只是从@HystrixCommand获得配置。

HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(commandKey);
HystrixReporter.reportMetric(HystrixCommandMetrics.getInstance(commandKey), text -> logger.debug(text));

我可以使用@HystrixCommand配置Hystric命令,但需要动态运行时配置。

以下是我build.gradle的摘录。

springBootVersion = '1.5.4.RELEASE'

...

ext {
    springCloudVersion = 'Dalston.SR1'
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.cloud:spring-cloud-starter-config')
    compile('org.springframework.cloud:spring-cloud-starter-feign')
    compile('org.springframework.cloud:spring-cloud-starter-hystrix')
    compile('org.springframework.integration:spring-integration-jms')

我一直看到这个评论所以它应该“正常”工作:

  

外部配置:从Spring Environment到Archaius的桥梁

以下是Spring Cloud Config服务器提供的application.yml

hystrix:
  command:
    default:
      circuitBreaker:
        enabled: true
        requestVolumeThreshold: 20
        sleepWindowInMilliseconds: 20000
      execution:
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 10000
        timeout:
          enabled: true
      metrics:
        rollingStats:
          numBuckets: 200
          timeInMilliseconds: 10000

  threadpool:
    default:
      coreSize: 10
      maximumSize: 10
      maxQueueSize: -1

  metrics:
    polling-interval-ms: 5000

0 个答案:

没有答案
相关问题