Ren*_*ier 12 java spring-data spring-boot netflix-feign
使用在SQL Server中执行查询的服务时,我的应用程序遇到错误FeignClient.
错误:
线程"pool-10-thread-14"中的异常feign.RetryableException:读取超时执行GET http://127.0.0.1:8876/processoData/search/buscaProcessoPorCliente?cliente=ELEKTRO+-+TRABALHISTA&estado=SP
我的消费者服务:
@FeignClient(url="http://127.0.0.1:8876")
public interface ProcessoConsumer {
@RequestMapping(method = RequestMethod.GET, value = "/processoData/search/buscaProcessoPorCliente?cliente={cliente}&estado={estado}")
public PagedResources<ProcessoDTO> buscaProcessoClienteEstado(@PathVariable("cliente") String cliente, @PathVariable("estado") String estado);
}
Run Code Online (Sandbox Code Playgroud)
我的YML:
server:
port: 8874
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://xxx.xx.xxx.xx:8764}/eureka/
instance:
preferIpAddress: true
ribbon:
eureka:
enabled: true
spring:
application:
name: MyApplication
data:
mongodb:
host: xxx.xx.xxx.xx
port: 27017
uri: mongodb://xxx.xx.xxx.xx/recortesExtrator
repositories.enabled: true
solr:
host: http://xxx.xx.xxx.xx:8983/solr
repositories.enabled: true
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
谢谢.
cha*_*lvi 18
在Application.properties文件中添加以下属性.
feign.client.config.default.connectTimeout: 160000000
feign.client.config.default.readTimeout: 160000000
Run Code Online (Sandbox Code Playgroud)
我正在使用Feign.builder()实例化我的 Feign 客户端。
为了设置connectTimeoutand readTimeout,我使用以下内容:
Feign.builder()
...
.options(new Request.Options(connectTimeout, readTimeout))
.target(MyApiInterface.class, url);
Run Code Online (Sandbox Code Playgroud)
使用它我可以为不同的 API 配置不同的超时。
刚刚也遇到了这个问题。正如@spencergibb 所建议的,这里是我正在使用的解决方法。见链接
在 application.properties 中添加这些。
# Disable Hystrix timeout globally (for all services)
hystrix.command.default.execution.timeout.enabled: false
# Increase the Hystrix timeout to 60s (globally)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
Run Code Online (Sandbox Code Playgroud)
Add this in the Java configuration class.
import feign.Request;
@Configuration
@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = { ServiceFeignClient.class })
@ComponentScan(basePackageClasses = { ServiceFeignClient.class })
public class FeignConfig {
/**
* Method to create a bean to increase the timeout value,
* It is used to overcome the Retryable exception while invoking the feign client.
* @param env,
* An {@link ConfigurableEnvironment}
* @return A {@link Request}
*/
@Bean
public static Request.Options requestOptions(ConfigurableEnvironment env) {
int ribbonReadTimeout = env.getProperty("ribbon.ReadTimeout", int.class, 70000);
int ribbonConnectionTimeout = env.getProperty("ribbon.ConnectTimeout", int.class, 60000);
return new Request.Options(ribbonConnectionTimeout, ribbonReadTimeout);
}
}
Run Code Online (Sandbox Code Playgroud)
Mar*_*one -2
看看这个答案。它对我有用。我还做了一些研究,在这里找到了属性文档:
https://github.com/Netflix/Hystrix/wiki/Configuration#intro