Simplify HTTP API with Feign Client

In the previous chapters, we developed microservices and client applications for these microservices using load-balancing RestTemplate, EurekaClient, and DiscoveryClient. This way of client implementation requires a lot of boilerplate code for enabling microservices to communicate with each other. In light of these discussions, we will learn about Feign, which is nothing but a declarative HTTP client developed by Netflix.

In this chapter, we will explore what Feign is and how it works. We will also have a detailed discussion on how Feign can be extended or customized for business needs with a reference implementation for a custom encoder, decoder, Hystrix, and exception handling with unit testing.

We will learn how Feign simplifies the HTTP API clients. We don't need to use a lot of boilerplate code to make the HTTP API clients application to access the microservices. You just simply put in an annotated interface, while the actual implementation will be created at the runtime.

By the end of this chapter, you will have a better understanding of the declarative REST client, Feign client, and how to access the microservices using only annotated interfaces without implementing these interfaces by yourself.

This chapter will cover the following points:

  • Feign basics
  • Feign inheritance support
  • Multiple interfaces
  • Advanced usage
  • Feign and Hystrix
  • Logging
  • Exception handling
  • Custom encoders and decoders
  • Unit testing Feign clients

Let's look at these topics in detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.150.123