Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud Feign Non blocking I/O or Asynchronous Call

I am developing microservices using Spring cloud platform where service1 calls multiple other micro services e.g. service2, service3, service 4 etc. These services can be called in parallel and service1 will aggregate the result. Can I use Spring cloud feign (http://cloud.spring.io/spring-cloud-static/Dalston.SR1/#spring-cloud-feign) to generate rest client and call the services asynchronously or Should I use Spring 4 AsyncRestTemplate to call the services asynchronously?

like image 916
Debopam Avatar asked Jun 12 '17 21:06

Debopam


People also ask

Is feign client synchronous or asynchronous?

The API that we defined via Feign is synchronous — meaning that it makes blocking calls to the server. Feign allows us to easily define async APIs as well — utilizing CompletableFutures under the hood.

Is feign client non-blocking?

Reactive Feign is great choice for the implementation of non-blocking API clients. It is a reactive version of OpenFeign which supports the creation of API clients without the need to writing implementation code.

What is the difference between RestTemplate and feign client?

When we use the RestTemplate to call the RESTful service, it creates duplication of code that talks to RESTful services. When we define Feign, we need only to define a proxy and define a single method into it. Feign helps us to simplify client code to talk to the RESTful web services.

How feign client works internally?

A central concept in Spring Cloud's Feign support is that of the named client. Each feign client is part of an ensemble of components that work together to contact a remote server on demand, and the ensemble has a name that you give it as an application developer using the @FeignClient annotation.


1 Answers

I have used CompletableFuture to chain async calls to mutiple micro services using feign client however was not eventually successful. Please go through below link for further information. What I understood is - Feign's is not designed for asynchronous invocation or zero-copy i/o.

https://github.com/OpenFeign/feign/issues/361

like image 74
Rajesh Yerur Avatar answered Sep 21 '22 08:09

Rajesh Yerur