Kristoffer
Kristoffer

Reputation: 420

Why is the Ribbon HttpClient used to back RestTemplate in Spring Cloud Netflix?

So. We started working with the Spring Cloud (and Spring Cloud Netflix) library to get service discovery and client-side load balancing in our Spring Boot-based services. Part of the reason was I also, incorrectly, though it would also support the retrying that seems to be very important in a setup like that.

Another question has explained that is not actually the case. Fair enough but the documentation could have been clear on that. Would have saved me from some wrong assumptions at least.

But after investigating the code. I cannot figure out why Ribbon HttpClient is used at all? The load balancer support is currently implemented with Ribbon.

But the code that does the actual HTTP request only deals with that though the Spring Cloud abstracted API. So it seems fairly pointless specifically use a (now deprecated) HttpClient from Ribbon when it could as well has used the implementation Spring RestTemplate would default to.

Seems like it would be a lot easier to understand the behavior of if it behaved like whatever client RestTemplate is configured to use or actually behaved like the Ribbon client with the support for configuring it to do what is supposed to be able to do (like retry).

Upvotes: 3

Views: 3248

Answers (1)

Tyler Van Gorder
Tyler Van Gorder

Reputation: 463

Kristoffer,

I also was looking for re-try logic in the load balanced RestTemplate and it turned out the RestClient (even though its been deprecated) does have support for fail-over and a small change to the request factory seems to work for me.

Here is a link

Upvotes: 1

Related Questions