Reddit Feeds

Sign up and stay connected to your favorite communities.

sign uplog in
34

Is there any reason to use Square/Retrofit over Netflix/Feign?

My team has been discussing moving from Square/Retrofit to Netflix/Feign for one of our projects.

After reading through the project readme, it appears Feign is basically Retrofit but more. At first glance I'm really excited for the integrated Hystrix support and the single-inheritance interfaces.

4 comments
99% Upvoted

I'm no pro on feign (just looked at it on your prompt). It looks like feign doesn't support as many use cases for callback style code, either rxjava or a literal callback (retrofit 1) or the new call (syncro)/enqueue (async) from retrofit 2.

Personally I also find the API to be cleaner on retrofit one example is @POST("/account/{id}) vs @RequestLine("POST /account/{id}").

Glad to see the competition though to make both better!

Reading the GitHub README, I see that Feign also supports the @GET and @POST thing, via an extension called JaxRSContract.

Still, I don't see anything about callbacks -- and yet, the extensibility of Feign seems to be somewhat impressive.

5 points·2 years ago·edited 2 years ago

I've used both on a couple of projects. I preferred Retrofit:

  • Has @QueryMapannotation out of the box to pass multiple query parameters as a Map. You can accomplish something similar with Feign and its Encoder, but it's not as intuitive. I would often forget to set the Encoder and it would blow up at runtime.

  • Retrofit 2 has support for pagination URLs. I didn't see an equivalent for Feign. To be fair though, I didn't really check that extensively.

  • @GET and @POST are more dummy proof. I remember doing @RequestLine("POST/api/blah") (no space) and not getting an error until runtime. There's also the added benefit that you can use your IDE to search for those annotations.

  • Retrofit 2 introduces the Call abstraction which gives you headers when you need it. It's nice to have the option.

When I evaluated them, Feign was missing the ability to set arbitrary HTTP headers on a per-request basis, which I needed for a particular REST service's authentication.

But it's been a while, maybe they have the feature now.

Community Details

89.5k

Subscribers

267

Online

News, Technical discussions, research papers and assorted things of interest related to the Java programming language NO programming help, NO learning Java related questions!

Create Post

r/java Rules

1.
Programming help
2.
Trolling
3.
Jokes / Memes
4.
No Tutorials
5.
No Surveys
6.
No Job offers