Differences between netflix.feign & openfeign

15,398

Solution 1

org.springframework.cloud.netflix.feign is a part of Spring Cloud Netflix project which is a part of Spring Cloud.

Spring Cloud uses OpenFeign under the hood. It extends it to support Spring MVC annotations and makes it a first-class citizen in the Spring Environment by providing integrations for Spring Boot apps through autoconfiguration.

From the documentation:

Feign is a declarative web service client. 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.

Note that in the documentation there is a link to OpenFeign project.

So if you use Spring Boot - it is better and easier to use Spring Cloud OpenFeign integrations.

See also the source code.

Solution 2

"Netflix feign" is the old project designation. The last version (dependency below) is dated July 2016.

compile group: 'com.netflix.feign', name: 'feign-core', version:'8.18.0'   // OLD

"Open feign" is the new project designation. It's the same project, but was moved to a different git repo and got a new group-id. Its versions start at 9.0.0.

compile group: 'io.github.openfeign', name: 'feign-core', version: '10.0.1'   // NEW

See this github issue for a brief history of what happened. Most remarkably, you'll find out that Feign isn't used internally at Netflix anymore. :^o

Share:
15,398
Menelaos
Author by

Menelaos

Updated on June 20, 2022

Comments

  • Menelaos
    Menelaos almost 2 years

    Introduction

    I recently used netflix feign along with ribbon which was quite useful.

    An Example of this is:

    @FeignClient(name = "ldap-proxy")
    public interface LdapProxyClient  { 
        @RequestMapping(path = "/ldap-proxy/v1/users/{userNameOrEMail}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
        LdapUser search(@PathVariable("userNameOrEMail") String userNameOrEMail);
    }
    

    However, at some point I thought that instead of having to code all these definitions by hand (for an existing webservice), that I should see if a tool existed.

    I stumbled across https://github.com/swagger-api/swagger-codegenand saw that there are examples in which clients are generated, e.g. https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/java/feign .

    However, once I looked closely at the imports I noticed the following:

    import feign.Feign;

    Netflix's opensource solution on the other hand has package names: org.springframework.cloud.netflix.feign.

    Additionally, I noticed that both use ribbon if available, but Netflix's notation is much cleaner with a lot happenning in the background. E.g. the @FeignClient annotation class javadoc states:

    • Annotation for interfaces declaring that a REST client with that interface should be * created (e.g. for autowiring into another component). If ribbon is available it will be * used to load balance the backend requests, and the load balancer can be configured * using a @RibbonClient with the same name (i.e. value) as the feign client.

    However in the Feign.feign documentation (at https://github.com/OpenFeign/feign ) I see:

    RibbonClient overrides URL resolution of Feign's client, adding smart routing and resiliency capabilities provided by Ribbon.

    Integration requires you to pass your ribbon client name as the host part of the url, for example myAppProd.

    > MyService api =
    > Feign.builder().client(RibbonClient.create()).target(MyService.class,
    > "https://myAppProd");
    

    So my questions are:

    1. what is the history/relationship and differences between the two?
    2. what are the pros and cons of each?

    Are they completely different projects with no relation, or did netflix just fork/utilize OpenFeign and modify it to be within their integrated cloud solution? Essentially, did netflix just acquire and integrate different technologies like Discovery, ribbon, and feign from open-source projects?