Rom*_*nov 7 java hystrix feign
我有这个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")
Run Code Online (Sandbox Code Playgroud)
我也有Feign客户端:
@FeignClient(name = "client")
public interface FeignService {
@RequestMapping(value = "/path", method = GET)
String response();
}
Run Code Online (Sandbox Code Playgroud)
我的application.properties:
client.ribbon.listOfServers = http://localhost:8081
ribbon.eureka.enabled=false
Run Code Online (Sandbox Code Playgroud)
当查询时间超过1秒时,我得到异常:
com.netflix.hystrix.exception.HystrixRuntimeException: response timed-out and no fallback available.
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:如何设置自定义Feign客户端连接超时?例如2秒.
Rom*_*nov 17
我用这个解决我的问题的回答上一个问题:猬命令失败,"超时并没有可用的备用".
我添加hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=4000到我application.properties的设置自定义超时.