spring-cloud-feign

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

@EnableFeignClients and @FeignClient fail on Autowiring 'FeignContext' NoSuchBeanException

随声附和 提交于 2019-12-04 02:36:18
The microservice I'm writting needs to communicate to other microservices in our platform. On that attempt, the ideal solution for us is Spring Cloud Netflix Feign , implemeting a @FeignClient . However, I'm facing the exception below when I try an @Autowired ReviewProvider : Exception (cause) Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.netflix.feign.FeignContext' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:353) at org

How can I change the feign URL during the runtime?

橙三吉。 提交于 2019-12-03 08:21:40
@FeignClient(name = "test", url="http://xxxx") How can I change the feign URL (url="http://xxxx") during the runtime? because the URL can only be determined at run time. Sandip Nirmal Feign has a way to provide the dynamic URLs and endpoints at runtime. The following steps have to be followed: In the FeignClient interface we have to remove the URL parameter. We have to use @RequestLine annotation to mention the REST method (GET, PUT, POST, etc.): @FeignClient(name="customerProfileAdapter") public interface CustomerProfileAdaptor { // @RequestMapping(method=RequestMethod.GET, value="/get_all")

Feign Client Error Handling

廉价感情. 提交于 2019-12-02 07:03:16
问题 I am using Feign Client, I have a Location service. So I created a client for my LocationService using FeignClient. @FeignClient(url="http://localhost:9003/location/v1", name="location-service") public interface LocationControllerVOneClient { @RequestMapping(value = "/getMultipleLocalities", method = RequestMethod.POST) public Response<Map<Integer, Locality>> getMultipleLocalities(List<Integer> localityIds); @RequestMapping(value = "/getMultipleCities", method = RequestMethod.POST) public

Enabling Sleuth slows requests down (a lot)

萝らか妹 提交于 2019-12-01 08:54:41
问题 I use Spring Cloud Feign and Sleuth with a Zipkin server. My problem is that when I enable Sleuth, then any simple request takes at least 600ms. Note that for tests purposes, I've set the sampler percentage of Sleuth at 1. Can I do something to improve that? Here some log of a request which takes 25ms without Sleuth and 700ms with Sleuth. (user calls /teams which calls /cities): 13:46:46.064 [http-nio-8080-exec-3] DEBUG o.s.c.s.instrument.web.TraceFilter - Received a request to uri [/teams]

FeignClient throws instead of returning ResponseEntity with error http status

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 11:56:51
As I'm using ResponseEntity<T> as return value for my FeignClient method, I was expecting it to return a ResponseEntity with 400 status if it's what the server returns. But instead it throws a FeignException . How can I get a proper ResponseEntity instead of an Exception from FeignClient ? Here is my FeignClient: @FeignClient(value = "uaa", configuration = OauthFeignClient.Conf.class) public interface OauthFeignClient { @RequestMapping( value = "/oauth/token", method = RequestMethod.POST, consumes = MULTIPART_FORM_DATA_VALUE, produces = APPLICATION_JSON_VALUE) ResponseEntity<OauthTokenResponse

How to send POST request by Spring cloud Feign

六眼飞鱼酱① 提交于 2019-11-29 09:28:35
问题 It's my Feign interface @FeignClient( name="mpi", url="${mpi.url}", configuration = FeignSimpleEncoderConfig.class ) public interface MpiClient { @RequestMapping(method = RequestMethod.POST) public ResponseEntity<String> getPAReq(@QueryMap Map<String, String> queryMap ); } and my custom configuration public class FeignSimpleEncoderConfig { public static final int FIVE_SECONDS = 5000; @Bean public Logger.Level feignLogger() { return Logger.Level.FULL; } @Bean public Request.Options options() {

FeignClient throws instead of returning ResponseEntity with error http status

╄→尐↘猪︶ㄣ 提交于 2019-11-28 05:36:58
问题 As I'm using ResponseEntity<T> as return value for my FeignClient method, I was expecting it to return a ResponseEntity with 400 status if it's what the server returns. But instead it throws a FeignException . How can I get a proper ResponseEntity instead of an Exception from FeignClient ? Here is my FeignClient: @FeignClient(value = "uaa", configuration = OauthFeignClient.Conf.class) public interface OauthFeignClient { @RequestMapping( value = "/oauth/token", method = RequestMethod.POST,