netflix-feign

FeignClient in spring boot 2

僤鯓⒐⒋嵵緔 提交于 2019-12-04 19:34:52
问题 I am trying to migrate from spring boot 1.5 tio 2.0 and faced problem: I changed version of spring-cloud-netflix-core from 1.3.4.RELEASE to 2.0.1.RELEASE : <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-core</artifactId> <version>2.0.1.RELEASE</version> </dependency> Unfortunately, feign library imports failed: import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;

Spring Cloud: Feign and Http Connection Pooling

喜欢而已 提交于 2019-12-04 13:27:40
问题 Can anyone please tell me if the Spring Cloud Feign Client provides or supports Http Connection Pooling, and if so how to configure settings like pool size? I can't seem to find this in the official documentation. Thank you. 回答1: From investigation I will try to answer my own question: Spring Cloud Feign uses Netflix Feign. Netflix Feign in turn creates connections using java.net.HttpURLConnection which makes use of 'persistent connections' but not a connection pool. It is possible to

Feign: Retry depending on response status

给你一囗甜甜゛ 提交于 2019-12-04 12:51:22
问题 I am currently using Spring Cloud and Feign to consume a Microservice in my application. Since it can happen, that a database connection or the like fails in a single service instance, making it return 500 HTTP status code, I want to make sure, that the next server is retried by the service's clients. Currently, Ribbon's retry mechanism works like a charm when the service is not running at all, however it still returns instantly an error when it receives a 500 status code, without any retry.

How to fine-tune the Spring Cloud Feign client?

雨燕双飞 提交于 2019-12-04 09:07:51
The Spring Cloud doc says: If Hystrix is on the classpath, by default Feign will wrap all methods with a circuit breaker. That's good but how do I configure the Hystrix options to ignore certain exceptions? I've an ErrorDecoder implementation that maps HTTP status code to exceptions. If I put @HystrixCommand on the method, does Feign honor that? Our requirement is to log various details about every HTTP call made out to dependencies. Currently I've a decorated RestTemplate that does this. From what I see in the code and based on Dave Syer's answer here , Feign does't use a RestTemplate . So

FeignClient in spring boot 2

你说的曾经没有我的故事 提交于 2019-12-04 02:48:35
I am trying to migrate from spring boot 1.5 tio 2.0 and faced problem: I changed version of spring-cloud-netflix-core from 1.3.4.RELEASE to 2.0.1.RELEASE : <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-core</artifactId> <version>2.0.1.RELEASE</version> </dependency> Unfortunately, feign library imports failed: import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.FeignAutoConfiguration; import org.springframework.cloud.netflix.feign.FeignClient; There is no library .feign in new 2.0.1

How to solve Timeout FeignClient

感情迁移 提交于 2019-12-04 00:26:17
My application is getting below error when consuming a service that performs queries in SQL Server using FeignClient . ERROR: Exception in thread "pool-10-thread-14" feign.RetryableException: Read timed out executing GET http://127.0.0.1:8876/processoData/search/buscaProcessoPorCliente?cliente=ELEKTRO+-+TRABALHISTA&estado=SP My Consumer Service: @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>

Unreachable security context using Feign RequestInterceptor

我是研究僧i 提交于 2019-12-03 14:22:34
The goal is to attach some data from security context using RequestInterceptor, but the problem, that the calling SecurityContextHolder.getContext().getAuthentication() always returns null even though it is not null (I am sure 100%). As I understand that's because the Interceptor is created and is being run in other thread. How could I solve this problem and get actual data from security context? My service: @FeignClient(value = "api", configuration = { FeignConfig.class }) public interface DocumentService { @RequestMapping(value = "/list", method = RequestMethod.GET) DocumentListOperation

Netflix Feign - Propagate Status and Exception through Microservices

对着背影说爱祢 提交于 2019-12-03 09:53:20
I'm using Netflix Feign to call to one operation of a Microservice A to other other operation of a Microservice B which validates a code using Spring Boot. The operation of Microservice B throws an exception in case of the validation has been bad. Then I handled in the Microservices and return a HttpStatus.UNPROCESSABLE_ENTITY (422) like next: @ExceptionHandler({ ValidateException.class }) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseBody public Object validationException(final HttpServletRequest request, final validateException exception) { log.error(exception.getMessage(),

How to Set Request Headers Using a Feign Client?

一个人想着一个人 提交于 2019-12-03 08:41:37
We are developing a suite of Microservices using Spring Cloud framework and one of the the things that we need to do is to set request headers. I know I can pass a parameter @RequestHeader to a Feign method but the value needs to come from another bean. I don't know if SPEL can be used for a Feign param value. I was thinking that this is a common enough use case for most clients so there'd be some examples, but so far I've not found any. Of course I can dig through the Spring course code and try to override the default Feign configuration but it kinda defeats the purpose of a declarative

Feign: Retry depending on response status

偶尔善良 提交于 2019-12-03 08:21:22
I am currently using Spring Cloud and Feign to consume a Microservice in my application. Since it can happen, that a database connection or the like fails in a single service instance, making it return 500 HTTP status code, I want to make sure, that the next server is retried by the service's clients. Currently, Ribbon's retry mechanism works like a charm when the service is not running at all, however it still returns instantly an error when it receives a 500 status code, without any retry. Is it possible to configure the Feign clients or their underlying Ribbon load balancers to retry the