In this tutorial, we're going to describe the differences between Spring Cloud Netflix Feign and Spring Cloud OpenFeign.
Feign makes writing web service clients easier by providing annotation support that allows us to implement our clients with just interfaces.
Originally, Feign was created and released by Netflix as part of their Netflix OSS project. Today, it is an open-source project.
2.1. Spring Cloud Netflix Feign
Spring Cloud Netflix integrates the Netflix OSS offerings into the Spring Cloud ecosystem. This includes Feign, Eureka, Ribbon, and a host of other tools and utilities. However, Feign was given its own Spring Cloud Starter to allow access to just Feign.
Ultimately, Netflix decided to stop using Feign internally and ceased its development. As a result of this decision, Netflix fully transferred Feign to the open-source community under a new project named OpenFeign.
Luckily, it continues to receive immense support from the open-source community and has seen many new features and updates.
2.3. Spring Cloud OpenFeign
Similar to its predecessor, Spring Cloud OpenFeign integrates the predecessor project into the Spring Cloud ecosystem.
Conveniently, this integration adds support for Spring MVC annotations and provides the same HttpMessageConverters.
Let's compare the Feign implementation found in the Spring Cloud OpenFeign to one using Spring Cloud Netflix Feign.
First, we must add the spring-cloud-starter-feign and spring-cloud-dependencies dependencies to our pom.xml file:
Please note that this library only works with Spring Boot 1.4.7 or earlier. Therefore our pom.xml must use compatible versions of any Spring Cloud dependencies.
4. Implementation with Spring Cloud Netflix Feign
Now, we can use @EnableFeignClients to enable component scanning for any interfaces that use @FeignClient.
For every example that we developed using the Spring Cloud Netflix Feign project, we use the following imports:
The implementation of all features is exactly the same for the old and the new version.
5. Implementation with Spring Cloud OpenFeign
Comparatively, our Spring Cloud OpenFeign tutorial contains the same example as the implementation with Spring Netflix Feign.
The only difference here is that our imports are from a different package:
Everything else is the same, which should come as no surprise due to the relation between these two libraries.
Fundamentally, these two implementations of Feign are identical. We can ascribe this to Netflix Feign being the ancestor of OpenFeign.
However, Spring Cloud OpenFeign includes new options and features that are not available in Spring Cloud Netflix Feign.
Recently, we can get support for Micrometer, Dropwizard Metrics, Apache HTTP Client 5, Google HTTP client, and many more.
This article compared the Spring Cloud integrations of OpenFeign and Netflix Feign. As usual, you'll find the sources over on GitHub for both Spring Cloud OpenFeign and Netflix Feign.