18

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?

Menelaos
  • 20,773
  • 14
  • 71
  • 130

2 Answers2

21

"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

Paulo Merson
  • 9,709
  • 5
  • 63
  • 56
  • Yea i'm still sad FeignTown never became a thing :/ – Naruto Sempai Oct 28 '18 at 18:31
  • 1
    api group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.1.2.RELEASE' then how come it is there in spring cloud also – P Satish Patro Jun 24 '20 at 10:34
  • 1
    @PSatishPatro The Spring framework encapsulates several libraries and other frameworks to make them easier to manage and use in Spring Boot applications (mostly by leveraging Spring's IoC). So, Spring Cloud Openfeign is a wrapper on openfeign. Similarly, you can use Kafka directly using Kafka's producer/consumer APIs or using Spring Kafka. – Paulo Merson Jun 25 '20 at 12:18
19

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.

Eien
  • 827
  • 6
  • 11
  • 3
    The Spring integration is that, integration with spring, built on top of openfeign. OpenFeign was transfered from netflix, so it is the same project with a new name and groupId and artifact id. – spencergibb Apr 13 '18 at 19:39
  • Here are the repos of both projects: [Spring-Cloud](https://github.com/spring-cloud/spring-cloud-openfeign) and [OpenFeign](https://github.com/OpenFeign/feign) – dbaltor Jul 07 '20 at 19:01