You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/spring-cloud-commons.adoc
+2-32Lines changed: 2 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -389,18 +389,10 @@ CAUTION: A `RestTemplate` bean is no longer created through auto-configuration.
389
389
Individual applications must create it.
390
390
391
391
The URI needs to use a virtual host name (that is, a service name, not a host name).
392
-
The Ribbon client is used to create a full physical address.
393
-
See {githubroot}/spring-cloud-netflix/blob/master/spring-cloud-netflix-ribbon/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[`RibbonAutoConfiguration`] for the details of how the `RestTemplate` is set up.
392
+
The BlockingLoadBalancerClient is used to create a full physical address.
394
393
395
394
IMPORTANT: To use a load-balanced `RestTemplate`, you need to have a load-balancer implementation in your classpath.
396
-
The recommended implementation is `BlockingLoadBalancerClient`.
397
395
Add <<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> to your project in order to use it.
398
-
The
399
-
`RibbonLoadBalancerClient` also can be used, but it's now under maintenance and we do not recommend adding it to new projects.
400
-
401
-
WARNING: By default, if you have both `RibbonLoadBalancerClient` and `BlockingLoadBalancerClient`, to
402
-
preserve backward compatibility, `RibbonLoadBalancerClient` is used.
403
-
To override it, you can set the `spring.cloud.loadbalancer.ribbon.enabled` property to `false`.
404
396
405
397
[[webclinet-loadbalancer-client]]
406
398
=== Spring WebClient as a Load Balancer Client
@@ -434,29 +426,19 @@ public class MyClass {
434
426
====
435
427
436
428
The URI needs to use a virtual host name (that is, a service name, not a host name).
437
-
The Ribbon client or Spring Cloud LoadBalancer is used to create a full physical address.
429
+
The Spring Cloud LoadBalancer is used to create a full physical address.
438
430
439
431
IMPORTANT: If you want to use a `@LoadBalanced WebClient.Builder`, you need to have a load balancer
440
432
implementation in the classpath. We recommend that you add the
441
433
<<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> to your project.
442
434
Then, `ReactiveLoadBalancer` is used underneath.
443
-
Alternatively, this functionality also works with `spring-cloud-starter-netflix-ribbon`, but the request
444
-
is handled by a non-reactive `LoadBalancerClient` under the hood. Additionally,
445
-
`spring-cloud-starter-netflix-ribbon` is already in maintenance mode, so we do not recommend
446
-
adding it to new projects.
447
-
If you have both `spring-cloud-starter-loadbalancer` and `spring-cloud-starter-netflix-ribbon`
448
-
in your classpath, Ribbon is used by default. To switch to Spring Cloud LoadBalancer,
449
-
set the `spring.cloud.loadbalancer.ribbon.enabled` property to `false`.
450
435
451
436
==== Retrying Failed Requests
452
437
453
438
A load-balanced `RestTemplate` can be configured to retry failed requests.
454
439
By default, this logic is disabled.
455
440
You can enable it by adding link:https://github.com/spring-projects/spring-retry[Spring Retry] to your application's classpath.
456
-
The load-balanced `RestTemplate` honors some of the Ribbon configuration values related to retrying failed requests.
457
-
You can use `client.ribbon.MaxAutoRetries`, `client.ribbon.MaxAutoRetriesNextServer`, and `client.ribbon.OkToRetryOnAllOperations` properties.
458
441
If you would like to disable the retry logic with Spring Retry on the classpath, you can set `spring.cloud.loadbalancer.retry.enabled=false`.
459
-
See the https://github.com/Netflix/ribbon/wiki/Getting-Started#the-properties-file-sample-clientproperties[Ribbon documentation] for a description of what these properties do.
460
442
461
443
If you would like to implement a `BackOffPolicy` in your retries, you need to create a bean of type `LoadBalancedRetryFactory` and override the `createBackOffPolicy` method:
462
444
@@ -478,8 +460,6 @@ public class MyConfiguration {
478
460
----
479
461
====
480
462
481
-
NOTE: `client` in the preceding examples should be replaced with your Ribbon client's name.
482
-
483
463
If you want to add one or more `RetryListener` implementations to your retry functionality, you need to
484
464
create a bean of type `LoadBalancedRetryListenerFactory` and return the `RetryListener` array
485
465
you would like to use for a given service, as the following example shows:
@@ -649,16 +629,9 @@ public class MyClass {
649
629
The URI needs to use a virtual host name (that is, a service name, not a host name).
650
630
The `ReactorLoadBalancer` is used to create a full physical address.
651
631
652
-
NOTE: By default, if you have `spring-cloud-netflix-ribbon` in your classpath, <<load-balancer-exchange-filter-function,`LoadBalancerExchangeFilterFunction`>>
653
-
is used to maintain backward compatibility. To use
654
-
`ReactorLoadBalancerExchangeFilterFunction`, set the `spring.cloud.loadbalancer.ribbon.enabled` property
655
-
to `false`.
656
-
657
632
[[load-balancer-exchange-filter-function]]
658
633
==== Spring WebFlux `WebClient` with a Non-reactive Load Balancer Client
659
634
660
-
If you you do not have <<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> in your project
661
-
but you do have spring-cloud-starter-netflix-ribbon, you can still use `WebClient` with `LoadBalancerClient`.
662
635
If `spring-webflux` is on the classpath, `LoadBalancerExchangeFilterFunction`
663
636
is auto-configured. Note, however, that this
664
637
uses a non-reactive client under the hood.
@@ -1004,9 +977,6 @@ NOTE: Spring Cloud LoadBalancer starter includes
and https://github.com/stoyanr[Evictor].
1006
979
1007
-
WARNING: If you have both Ribbon and Spring Cloud LoadBalancer int the classpath, in order to maintain backward compatibility, Ribbon-based implementations will be used by default.
1008
-
In order to switch to using Spring Cloud LoadBalancer under the hood, make sure you set the property `spring.cloud.loadbalancer.ribbon.enabled` to `false`.
1009
-
1010
980
[[custom-loadbalancer-configuration]]
1011
981
=== Passing Your Own Spring Cloud LoadBalancer Configuration
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfiguration.java
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerAutoConfiguration.java
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerBeanPostProcessorAutoConfiguration.java
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerExchangeFilterFunction.java
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/OnNoRibbonDefaultCondition.java
Copy file name to clipboardExpand all lines: spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/ReactiveLoadBalancerAutoConfiguration.java
0 commit comments