java - 使用默认设置时使用哪个 Spring Cloud Zuul 超时属性?

标签 java spring-boot spring-cloud netflix-zuul gateway

我正在设置(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 中的屏幕截图,其中仅建议其他属性: enter image description here

默认情况下,此 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 配合使用,

https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_service_discovery_configuration

注意:属性区分大小写

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/

相关文章:

Java套接字错误: java.net.ConnectException:连接被拒绝:连接

java - 用于异步客户端到客户端消息传递的库

java - 在 MyBatis 中使用基于 resultType 的隐式 TypeHandler 进行选择

java - 从过滤器中的数据库对用户进行身份验证是一种好习惯吗?

spring-boot - 如何向 IntelliJ IDEA Community Edition 2020 添加 Spring Initializr 支持

java - 在另一个类中访问一个类的变量

java - 仅将 https 与 spring cloud 微服务实例一起使用

java - 启动消费者时抛出异常 - (无法为微服务中的不同 channel 分配相同的组名称)

java - 为生产环境配置 Spring Cloud Config Server 和 Spring Cloud Vault

java - [Spring-Cloud][Maven][Docker]Feign接口(interface)应该放在FeignClients还是EurekaClients中?