3

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).

Community
  • 1
  • 1
Kristoffer
  • 410
  • 2
  • 6
  • 16
  • The Netflix team specifically request it. – spencergibb Nov 16 '15 at 16:04
  • 1
    Don't quite understand this. The Netflix team specifically requested that you call a deprecated wrapper for Jersey that calls Apache HttpClient instead of using a different Spring ClientHttpRequestFactory to get the actual HTTP Client? As far as I can tell all RibbonClientHttpRequestFactory needs to do is to resolve a service instance address. – Kristoffer Nov 17 '15 at 15:26

1 Answers1

1

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

Community
  • 1
  • 1
Tyler Van Gorder
  • 453
  • 6
  • 14
  • Nice. We actually have a dynamic proxy on the RestTemplate anyway - to solve a different issue. So I ended up adding a Spring Retry RetryTemplate around the calls. That works as a solution for now. – Kristoffer Nov 18 '15 at 18:14