Iniciando com Feign
What is the Feign?
Feign is a declarative web service client. It makes writing web service clients easier. To use Feign create an interface and annotate it. It has pluggable annotation support including Feign annotations and JAX-RS annotations. Feign also supports pluggable encoders and decoders. Spring Cloud adds support for Spring MVC annotations and for using the same HttpMessageConverters
used by default in Spring Web. Spring Cloud integrates Ribbon and Eureka to provide a load balanced http client when using Feign.
How to Include Feign
To include the Feign in your project, you need config the pom.xml.
This case, i used “spring-cloud-started-openfeign”.
Before config, you need add the annotation to start configuration the Feign.
@EnableFeignClients
My example
In my project, i created a simple client to call a service.
First, i created a client.
In my class, i used the @FeignClient for config the name and the url.
I created a method with config the service that i will call.
The last, i created a resource to my execute.
Test
curl http://localhost:8080/v1/refresh/
Conclusion
The example is the simple, for introduction the Feign, but Feign is power library.
The git project is: https://github.com/Infobec/feign-start
=========
Quer fazer vários cursos de microservice? Entre no site www.alcateiadev.com.br e lá tem cupons de desconto semanal.
=========