Skip to content

Commit

Permalink
Document using configurers and customisers with @LoadBalanced HTTP cl…
Browse files Browse the repository at this point in the history
…ient builders. Fixes gh-1407.
  • Loading branch information
OlgaMaciaszek committed Oct 17, 2024
1 parent 2bce95f commit 3402ea8
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ public class MyClass {
The URI needs to use a virtual host name (that is, a service name, not a host name).
The `BlockingLoadBalancerClient` is used to create a full physical address.

In order to leverage additional capabilities that Spring Boot provides for `RestTemplateBuilder` (for example, observability support) you may want to use the autoconfigured
`RestTemplateBuilderConfigurer` while creating the `@LoadBalanced RestTemplateBuilder` beans:

[source,java,indent=0]
----
@Configuration
public class MyConfiguration {
@LoadBalanced
RestTemplateBuilder loadBalancedRestTemplateBuilder(RestTemplateBuilderConfigurer configurer) {
return configurer.configure(new RestTemplateBuilder());
}
}
----

IMPORTANT: To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.

[[multiple-resttemplate-builder-beans]]
Expand Down

0 comments on commit 3402ea8

Please sign in to comment.