<p>If you want a <code>RestTemplate</code> that is not load-balanced, create a <code>RestTemplate</code> bean and inject it.
<p>If you want a <code>RestTemplate</code> that is not load-balanced, create a <code>RestTemplate</code> bean and inject it.
To access the load-balanced <code>RestTemplate</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:\</p>
To access the load-balanced <code>RestTemplate</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:</p>
</div>
</div>
<divclass="listingblock">
<divclass="listingblock">
<divclass="content">
<divclass="content">
@ -979,8 +980,8 @@ public class MyConfiguration {
}
}
public class MyClass {
public class MyClass {
@Autowired
@Autowired
private RestTemplate restTemplate;
private RestTemplate restTemplate;
@Autowired
@Autowired
@LoadBalanced
@LoadBalanced
@ -1022,9 +1023,54 @@ If you see errors such as <code>java.lang.IllegalArgumentException: Can not set
</div>
</div>
</div>
</div>
<divclass="sect2">
<divclass="sect2">
<h3id="loadbalanced-webclient"><aclass="anchor"href="#loadbalanced-webclient"></a><aclass="link"href="#loadbalanced-webclient">2.6. Spring WebFlux WebClient as a Load Balancer Client</a></h3>
<p>If you want a <code>WebClient</code> that is not load-balanced, create a <code>WebClient</code> bean and inject it.
To access the load-balanced <code>WebClient</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:</p>
<h3id="loadbalanced-webclient"><aclass="anchor"href="#loadbalanced-webclient"></a><aclass="link"href="#loadbalanced-webclient">2.7. Spring WebFlux WebClient as a Load Balancer Client</a></h3>
<divclass="sect3">
<divclass="sect3">
<h4id="webflux-with-reactive-loadbalancer"><aclass="anchor"href="#webflux-with-reactive-loadbalancer"></a><aclass="link"href="#webflux-with-reactive-loadbalancer">2.6.1. Spring WebFlux WebClient with ReactorLoadBalancerExchangeFilterFunction</a></h4>
<h4id="webflux-with-reactive-loadbalancer"><aclass="anchor"href="#webflux-with-reactive-loadbalancer"></a><aclass="link"href="#webflux-with-reactive-loadbalancer">2.7.1. Spring WebFlux WebClient with ReactorLoadBalancerExchangeFilterFunction</a></h4>
<divclass="paragraph">
<divclass="paragraph">
<p><code>WebClient</code> can be configured to use the <code>ReactiveLoadBalancer</code>.
<p><code>WebClient</code> can be configured to use the <code>ReactiveLoadBalancer</code>.
If you add <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> to your project,
If you add <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> to your project,
@ -1070,7 +1116,7 @@ to <code>false</code>.
</div>
</div>
</div>
</div>
<divclass="sect3">
<divclass="sect3">
<h4id="load-balancer-exchange-filter-function"><aclass="anchor"href="#load-balancer-exchange-filter-function"></a><aclass="link"href="#load-balancer-exchange-filter-function">2.6.2. Spring WebFlux WebClient with non-reactive Load Balancer Client</a></h4>
<h4id="load-balancer-exchange-filter-function"><aclass="anchor"href="#load-balancer-exchange-filter-function"></a><aclass="link"href="#load-balancer-exchange-filter-function">2.7.2. Spring WebFlux WebClient with non-reactive Load Balancer Client</a></h4>
<divclass="paragraph">
<divclass="paragraph">
<p>If you you don’t have <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> in your project,
<p>If you you don’t have <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> in your project,
but you do have spring-cloud-starter-netflix-ribbon, you can still use <code>WebClient</code> with <code>LoadBalancerClient</code>. <code>LoadBalancerExchangeFilterFunction</code>
but you do have spring-cloud-starter-netflix-ribbon, you can still use <code>WebClient</code> with <code>LoadBalancerClient</code>. <code>LoadBalancerExchangeFilterFunction</code>
@ -1101,15 +1147,14 @@ The following example shows how to configure a <code>WebClient</code> to use loa
The <code>LoadBalancerClient</code> is used to create a full physical address.</p>
The <code>LoadBalancerClient</code> is used to create a full physical address.</p>
</div>
</div>
<divclass="paragraph">
<divclass="paragraph">
<p>WARN:
<p>WARN: This approach is now deprecated.
This approach is now deprecated.
We suggest you use <ahref="#webflux-with-reactive-loadbalancer">WebFlux with reactive Load-Balancer</a>
We suggest you use <ahref="#webflux-with-reactive-loadbalancer">WebFlux with reactive Load-Balancer</a>
<p>Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container).
<p>Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container).
A list of regular expressions can be set to cause the desired network interfaces to be ignored.
A list of regular expressions can be set to cause the desired network interfaces to be ignored.
@ -1157,7 +1202,7 @@ The following configuration ignores the <code>docker0</code> interface and all i
<p>Spring Cloud Commons provides beans for creating both Apache HTTP clients (<code>ApacheHttpClientFactory</code>) and OK HTTP clients (<code>OkHttpClientFactory</code>).
<p>Spring Cloud Commons provides beans for creating both Apache HTTP clients (<code>ApacheHttpClientFactory</code>) and OK HTTP clients (<code>OkHttpClientFactory</code>).
The <code>OkHttpClientFactory</code> bean is created only if the OK HTTP jar is on the classpath.
The <code>OkHttpClientFactory</code> bean is created only if the OK HTTP jar is on the classpath.
@ -1168,14 +1213,14 @@ You can also disable the creation of these beans by setting <code>spring.cloud.h
<h3id="spring-cloud-compatibility-verification"><aclass="anchor"href="#spring-cloud-compatibility-verification"></a><aclass="link"href="#spring-cloud-compatibility-verification">2.10. Spring Cloud Compatibility Verification</a></h3>
<h3id="spring-cloud-compatibility-verification"><aclass="anchor"href="#spring-cloud-compatibility-verification"></a><aclass="link"href="#spring-cloud-compatibility-verification">2.11. Spring Cloud Compatibility Verification</a></h3>
<divclass="paragraph">
<divclass="paragraph">
<p>Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided
<p>Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided
to add a compatibility verification mechanism. It will break if your current setup is not compatible
to add a compatibility verification mechanism. It will break if your current setup is not compatible
<p>If you want a <code>RestTemplate</code> that is not load-balanced, create a <code>RestTemplate</code> bean and inject it.
<p>If you want a <code>RestTemplate</code> that is not load-balanced, create a <code>RestTemplate</code> bean and inject it.
To access the load-balanced <code>RestTemplate</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:\</p>
To access the load-balanced <code>RestTemplate</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:</p>
</div>
</div>
<divclass="listingblock">
<divclass="listingblock">
<divclass="content">
<divclass="content">
@ -979,8 +980,8 @@ public class MyConfiguration {
}
}
public class MyClass {
public class MyClass {
@Autowired
@Autowired
private RestTemplate restTemplate;
private RestTemplate restTemplate;
@Autowired
@Autowired
@LoadBalanced
@LoadBalanced
@ -1022,9 +1023,54 @@ If you see errors such as <code>java.lang.IllegalArgumentException: Can not set
</div>
</div>
</div>
</div>
<divclass="sect2">
<divclass="sect2">
<h3id="loadbalanced-webclient"><aclass="anchor"href="#loadbalanced-webclient"></a><aclass="link"href="#loadbalanced-webclient">2.6. Spring WebFlux WebClient as a Load Balancer Client</a></h3>
<p>If you want a <code>WebClient</code> that is not load-balanced, create a <code>WebClient</code> bean and inject it.
To access the load-balanced <code>WebClient</code>, use the <code>@LoadBalanced</code> qualifier when you create your <code>@Bean</code>, as shown in the following example:</p>
<h3id="loadbalanced-webclient"><aclass="anchor"href="#loadbalanced-webclient"></a><aclass="link"href="#loadbalanced-webclient">2.7. Spring WebFlux WebClient as a Load Balancer Client</a></h3>
<divclass="sect3">
<divclass="sect3">
<h4id="webflux-with-reactive-loadbalancer"><aclass="anchor"href="#webflux-with-reactive-loadbalancer"></a><aclass="link"href="#webflux-with-reactive-loadbalancer">2.6.1. Spring WebFlux WebClient with ReactorLoadBalancerExchangeFilterFunction</a></h4>
<h4id="webflux-with-reactive-loadbalancer"><aclass="anchor"href="#webflux-with-reactive-loadbalancer"></a><aclass="link"href="#webflux-with-reactive-loadbalancer">2.7.1. Spring WebFlux WebClient with ReactorLoadBalancerExchangeFilterFunction</a></h4>
<divclass="paragraph">
<divclass="paragraph">
<p><code>WebClient</code> can be configured to use the <code>ReactiveLoadBalancer</code>.
<p><code>WebClient</code> can be configured to use the <code>ReactiveLoadBalancer</code>.
If you add <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> to your project,
If you add <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> to your project,
@ -1070,7 +1116,7 @@ to <code>false</code>.
</div>
</div>
</div>
</div>
<divclass="sect3">
<divclass="sect3">
<h4id="load-balancer-exchange-filter-function"><aclass="anchor"href="#load-balancer-exchange-filter-function"></a><aclass="link"href="#load-balancer-exchange-filter-function">2.6.2. Spring WebFlux WebClient with non-reactive Load Balancer Client</a></h4>
<h4id="load-balancer-exchange-filter-function"><aclass="anchor"href="#load-balancer-exchange-filter-function"></a><aclass="link"href="#load-balancer-exchange-filter-function">2.7.2. Spring WebFlux WebClient with non-reactive Load Balancer Client</a></h4>
<divclass="paragraph">
<divclass="paragraph">
<p>If you you don’t have <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> in your project,
<p>If you you don’t have <ahref="#spring-cloud-loadbalancer-starter">Spring Cloud LoadBalancer starter</a> in your project,
but you do have spring-cloud-starter-netflix-ribbon, you can still use <code>WebClient</code> with <code>LoadBalancerClient</code>. <code>LoadBalancerExchangeFilterFunction</code>
but you do have spring-cloud-starter-netflix-ribbon, you can still use <code>WebClient</code> with <code>LoadBalancerClient</code>. <code>LoadBalancerExchangeFilterFunction</code>
@ -1101,15 +1147,14 @@ The following example shows how to configure a <code>WebClient</code> to use loa
The <code>LoadBalancerClient</code> is used to create a full physical address.</p>
The <code>LoadBalancerClient</code> is used to create a full physical address.</p>
</div>
</div>
<divclass="paragraph">
<divclass="paragraph">
<p>WARN:
<p>WARN: This approach is now deprecated.
This approach is now deprecated.
We suggest you use <ahref="#webflux-with-reactive-loadbalancer">WebFlux with reactive Load-Balancer</a>
We suggest you use <ahref="#webflux-with-reactive-loadbalancer">WebFlux with reactive Load-Balancer</a>
<p>Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container).
<p>Sometimes, it is useful to ignore certain named network interfaces so that they can be excluded from Service Discovery registration (for example, when running in a Docker container).
A list of regular expressions can be set to cause the desired network interfaces to be ignored.
A list of regular expressions can be set to cause the desired network interfaces to be ignored.
@ -1157,7 +1202,7 @@ The following configuration ignores the <code>docker0</code> interface and all i
<p>Spring Cloud Commons provides beans for creating both Apache HTTP clients (<code>ApacheHttpClientFactory</code>) and OK HTTP clients (<code>OkHttpClientFactory</code>).
<p>Spring Cloud Commons provides beans for creating both Apache HTTP clients (<code>ApacheHttpClientFactory</code>) and OK HTTP clients (<code>OkHttpClientFactory</code>).
The <code>OkHttpClientFactory</code> bean is created only if the OK HTTP jar is on the classpath.
The <code>OkHttpClientFactory</code> bean is created only if the OK HTTP jar is on the classpath.
@ -1168,14 +1213,14 @@ You can also disable the creation of these beans by setting <code>spring.cloud.h
<h3id="spring-cloud-compatibility-verification"><aclass="anchor"href="#spring-cloud-compatibility-verification"></a><aclass="link"href="#spring-cloud-compatibility-verification">2.10. Spring Cloud Compatibility Verification</a></h3>
<h3id="spring-cloud-compatibility-verification"><aclass="anchor"href="#spring-cloud-compatibility-verification"></a><aclass="link"href="#spring-cloud-compatibility-verification">2.11. Spring Cloud Compatibility Verification</a></h3>
<divclass="paragraph">
<divclass="paragraph">
<p>Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided
<p>Due to the fact that some users have problem with setting up Spring Cloud application, we’ve decided
to add a compatibility verification mechanism. It will break if your current setup is not compatible
to add a compatibility verification mechanism. It will break if your current setup is not compatible