首页 > 解决方案 > Edgware.Release 不能通过 hystrix.command.default 但 [serviceId] 配置 zuul 超时

问题描述

hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 30000

在我用我的 serviceId 替换“默认”之前,此属性不起作用。我刚刚看到 Edgware.Release 的文档使用默认的commandKey配置 zuul 超时。

更多信息,我在程序中调试时发现 hytrix 命令是RibbonCommand,并且 commandKey 始终等于我的 serviceId。而且我在spring cloud doc中找不到更改它的地方。

这是我的 application.yml

server:
  port: 80
spring:
  application:
    name: mofeng-pay-zuul
  ##zipkin:
  ##  base-url: http://localhost:7000
  ##sleuth:
  ##  sampler:
  ##    percentage: 1.0
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

logging:
  level:
    com:
      DEBUG
  file: ${JAVA_LOG_HOME}/zuul.log

zuul:
  ribbonIsolationStrategy: THREAD
  threadPool:
    useSeparateThreadPools: true
  host:
    connections: 500
    socket-timeout-millis: 30000
    connect-timeout-millis: 30000

ribbon:
  ReadTimeout: 10000
  ConnectTimeout: 10000
  MaxAutoRetries: 1
  MaxAutoRetriesNextServer: 1
  eureka:
    enabled: true
  eager-load:
    enabled: true
    clients: 
    - client-service


hystrix:
  command:
    client-service:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 30000

删除 hystrix 配置并附加配置,如下所示:

client-service:
  ribbon:
    ConnectTimeout: 10000
    ReadTimeout: 30000
    MaxTotalHttpConnections: 500
    MaxConnectionsPerHost: 100

它仍然不起作用。

标签: springspring-cloudspring-cloud-netflix

解决方案


这是在Edgware.SR1中更改的错误(实际上是一种改进)。

https://github.com/spring-cloud/spring-cloud-netflix/pull/2633

Edgware.RELEASE中,您不能使用带default键的 Hystrix 超时,因为超时是在代码中设置的功能区连接超时加上读取超时。在 Edgware.RELEASE 中设置超时的唯一方法是使用命令键(服务 ID)设置超时。

但它被改变了。请尝试使用Edgware.SR1或更高版本。


推荐阅读