Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between netflix.feign & openfeign

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?

like image 422
Menelaos Avatar asked Apr 13 '18 18:04

Menelaos


People also ask

What is the purpose of using Netflix feign?

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.

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.

Which is better feign or RestTemplate?

One of the advantages of using Feign over RestTemplate is that, we do not need to write any implementation to call the other services. So there is no need to write any unit test as there is no code to test in the first place.

What is feign and ribbon?

Ribbon is a client side load balancer which gives you a lot of control over the behaviour of HTTP and TCP clients. Feign already uses Ribbon, so if you are using @FeignClient then this section also applies. A central concept in Ribbon is that of the named client.

What is Netflix feign?

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.

What is the difference between Netflix feign and Spring Cloud openfeign?

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.

Is it possible to load balance Netflix ribbon with feign?

The previous code, there are chances of exceptions like NullPointer and is not optimal. We will see how the call is made much easier and cleaner using Netflix Feign. If the Netflix Ribbon dependency is also in the classpath, then Feign also takes care of load balancing by default.

Is openfeign the same thing as feign?

isnt it the same thing ? OpenFeign is the spiritual successor to Feign, originally provided by Netflix. The projects name was changed when the original project was released to the community. The correct dependency is spring-cloud-starter-openfeign.


1 Answers

"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

like image 96
Paulo Merson Avatar answered Sep 28 '22 12:09

Paulo Merson