我有一个使用以下Gradle依赖的Spring Boot应用程序:
compile("org.springframework.cloud:spring-cloud-starter-eureka")
compile("org.springframework.cloud:spring-cloud-starter-feign")
compile("org.springframework.cloud:spring-cloud-starter-ribbon")
compile("org.springframework.cloud:spring-cloud-starter-hystrix")
compile("org.springframework.cloud:spring-cloud-starter-config")
我也有Feign客户端:
@FeignClient(name = "client")
public interface FeignService {
@RequestMapping(value = "/path", method = GET)
String response();
}
我的 application.properties
文件:
client.ribbon.listOfServers = http://localhost:8081
ribbon.eureka.enabled=false
当查询时间超过1秒时,我会收到异常:
com.netflix.hystrix.exception.HystrixRuntimeException: response timed-out and no fallback available.
所以我的问题是: 如何设置自定义的Feign客户端连接超时时间? 例如设置为2秒。
hystrix.command."FeignService#sayHello(String)".execution.isolation.thread.timeoutInMilliseconds: 20000
。 - jihor