Feign

Feign Client request and response and URL Logging

≯℡__Kan透↙ 提交于 2019-12-24 18:41:38
问题 How I can log the payload of Feign client request, response and URL. do I have to Implement an Interceptor? Because my requirement is logging the request and response on a special table on the database. 回答1: Feign has out of box logging mechanism and it can be achieved through simple steps. If you are using spring-cloud-starter-feign Feign using Slf4jLogger for logging.Feign logging documentation As per doc, the below logging levels are available to configure, NONE - No logging (DEFAULT).

How to download File with open-feign

随声附和 提交于 2019-12-24 11:12:01
问题 How to download File with open-feign , it's possible? for example: @RequestLine("GET /file") File from (@Param("param") String param); 回答1: Are you using Spring? You can use this code: @RequestMapping( value = "/multipart/download/{fileId}", method = GET) MultipartFile[] download(@PathVariable("fileId") String fileId); Check the tutorial in the official Github. 来源: https://stackoverflow.com/questions/52744112/how-to-download-file-with-open-feign

How to call url with multiple query string params in FeignClient?

ⅰ亾dé卋堺 提交于 2019-12-23 12:14:42
问题 I try to call Google API with multiple query string parameters. And curiously, I can't find a way to do that. This is my FeignClient : @FeignClient(name="googleMatrix", url="https://maps.googleapis.com/maps/api/distancematrix/json") public interface GoogleMatrixClient { @RequestMapping(method=RequestMethod.GET, value="?key={key}&origins={origins}&destinations={destinations}") GoogleMatrixResult process(@PathVariable(value="key") String key, @PathVariable(value="origins") String origins,

Array Multipart[] file upload using Feign client

六月ゝ 毕业季﹏ 提交于 2019-12-12 21:08:03
问题 I am trying to upload Array of Multipart file object using feign client. This is the service am trying to call using Feign client. public ResponseEntity<Object> manageFileUpload(@RequestParam("files") MultipartFile[] files) I tried using,Feign client Annotation, @FeignClient(value = "UPLOADUTILITIES", configuration = Upload.MultipartSupportConfig.class, fallback = UploadFallback.class) My Method, @RequestMapping(name = "upload", value = "/object", method = RequestMethod.POST) @Headers(

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

只谈情不闲聊 提交于 2019-12-12 08:28:28
问题 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

How to implement Sleuth Tracing With Feign.Builder?

筅森魡賤 提交于 2019-12-11 01:48:20
问题 I'm trying to integrate Sleuth into our system. If I use interfaces annotated with @FeignClient , everything works fine. These interfaces get instrumented automatically, and Sleuth headers get propagated with REST calls. But, we have some existing code that uses Feign.Builder directly with Feign annotated interfaces (just not annotated with @FeignClient ). This code adds some custom request interceptors, encoder, proxy, etc. For example: // Feign REST interface public interface MyService {

How to fine-tune the Spring Cloud Feign client?

回眸只為那壹抹淺笑 提交于 2019-12-09 13:19:12
问题 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.

Body parameters cannot be used with form parameters - Feign client with Headers and json data

一笑奈何 提交于 2019-12-05 03:36:32
I have a FeignClient like this @RequestLine("POST /enroll") @Headers({ "header1: {header1}", "header2: {header2}", "Content-Type: application/json" }) ResponseDto enroll(@Param("header1") String header1,@Param("header1") String header1, RequestDto requestDto)throws MyCustomException; ` I am not using spring cloud netflix. But I am keep getting the below exception. Caused by: java.lang.IllegalStateException: Body parameters cannot be used with form parameters. at feign.Util.checkState(Util.java:128) at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:112) at feign.Contract

Spring Data Pageable not supported as RequestParam in Feign Client

情到浓时终转凉″ 提交于 2019-12-04 20:04:31
I have been trying to expose a Feign Client for my rest api. It takes Pageable as input and has PageDefaults defined. Controller: @GetMapping(value = "data", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get Data", nickname = "getData") public Page<Data> getData(@PageableDefault(size = 10, page = 0) Pageable page, @RequestParam(value = "search", required = false) String search) { return service.getData(search, page); } And here is my feign client: @RequestMapping(method = RequestMethod.GET, value = "data") public Page<Data> getData(@RequestParam(name = "pageable",

How to write integration tests with spring-cloud-netflix and feign

微笑、不失礼 提交于 2019-12-04 15:47:12
问题 I use Spring-Cloud-Netflix for communication between micro services. Let's say I have two services, Foo and Bar, and Foo consumes one of Bar's REST endpoints. I use an interface annotated with @FeignClient : @FeignClient public interface BarClient { @RequestMapping(value = "/some/url", method = "POST") void bazzle(@RequestBody BazzleRequest); } Then I have a service class SomeService in Foo, which calls the BarClient . @Component public class SomeService { @Autowired BarClient barClient;