我正在设置(Spring boot 2)Spring cloud zuul/网关并遇到超时问题。读完official docs后并检查similar question ,我不相信所提出的解决方案。
我使用以下类型的路由配置:
routes:
test-service:
path: /test-service/**
serviceId: test-service
我认为这不是“url 路由”,所以我认为这些属性不适用:
zuul.host.connect-timeout-millis
zuul.host.connection-request-timeout-millis
zuul.host.socket-timeout-millis
我尝试设置以下属性,但 IntelliJ 指示这些属性“不存在”。这是 IDE 中的一个怪癖,还是这些属性仅在某些情况下存在/Activity ?
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds= 11000
hystrix.command.default.execution.timeout.enabled=false
ribbon.ConnectTimeout= 10000
ribbon.ReadTimeout: 10000
例如请参阅我的 bootstrap.yml 中的屏幕截图,其中仅建议其他属性:
默认情况下,此 Maven 依赖项中的 Ribbon 和 hystrix 是否存在并处于 Activity 状态?
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
最佳答案
如果你想在 Zuul 中配置超时,你有两个选择,
如果您已将 Zuul 配置为使用服务发现,则需要使用以下功能区属性配置这些超时
ribbon.ReadTimeout
ribbon.SocketTimeout
如果您通过指定 URL 配置 Zuul 路由,则使用以下属性,根据您的配置,您需要使用此属性
zuul.host.connect-timeout-millis
zuul.host.socket-timeout-millis
官方文档在这里(查看 Zuul 超时部分)
https://cloud.spring.io/spring-cloud-netflix/multi/multi__router_and_filter_zuul.html
下面将展示它们如何与 Hystrix 配合使用,
注意:属性区分大小写
I tried setting the properties below, but IntelliJ indicates these properties "do not exist". Is this a quirk in the IDE, or are these properties only present/active under certain circumstances?
可能是 IDE 中的怪癖。我们有官方文档说该属性存在。
关于java - 使用默认设置时使用哪个 Spring Cloud Zuul 超时属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56358124/