diff --git a/multi/multi__spring_cloud_commons_common_abstractions.html b/multi/multi__spring_cloud_commons_common_abstractions.html index c03f73a3..e8130565 100644 --- a/multi/multi__spring_cloud_commons_common_abstractions.html +++ b/multi/multi__spring_cloud_commons_common_abstractions.html @@ -58,7 +58,7 @@ you would like to use for a given service.

[Note]Note

client in the above examples should be replaced with your Ribbon client’s -name.

2.4 Multiple RestTemplate objects

If you want a RestTemplate that is not load balanced, create a RestTemplate +name.

2.3.2 Multiple RestTemplate objects

If you want a RestTemplate that is not load balanced, create a RestTemplate bean and inject it as normal. To access the load balanced RestTemplate use the @LoadBalanced qualifier when you create your @Bean.

[Important]Important

Notice the @Primary annotation on the plain RestTemplate declaration in the example below, to disambiguate the unqualified @Autowired injection.

@Configuration
 public class MyConfiguration {
@@ -91,7 +91,21 @@ the @LoadBalanced qualifier when you create your public String doStuff() {
         return restTemplate.getForObject("http://example.com", String.class);
     }
-}
[Tip]Tip

If you see errors like java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89 try injecting RestOperations instead or setting spring.aop.proxyTargetClass=true.

2.5 Ignore Network Interfaces

Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".

application.yml.  +}

[Tip]Tip

If you see errors like java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89 try injecting RestOperations instead or setting spring.aop.proxyTargetClass=true.

2.4 Spring WebFlux WebClient as a Load Balancer Client

WebClient can be configured to use the LoadBalancerClient. A `LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath.

public class MyClass {
+    @Autowired
+    private LoadBalancerExchangeFilterFunction lbFunction;
+
+    public Mono<String> doOtherStuff() {
+        return WebClient.builder().baseUrl("http://stores")
+            .filter(lbFunction)
+            .build()
+            .get()
+            .uri("/stores")
+            .retrieve()
+            .bodyToMono(String.class);
+    }
+}

The URI needs to use a virtual host name (ie. service name, not a host name). +The LoadBalancerClient is used to create a full physical address.

2.5 Ignore Network Interfaces

Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".

application.yml. 

spring:
   cloud:
     inetutils:
diff --git a/multi/multi_spring-cloud-commons.html b/multi/multi_spring-cloud-commons.html
index 95bbb5c3..064776f7 100644
--- a/multi/multi_spring-cloud-commons.html
+++ b/multi/multi_spring-cloud-commons.html
@@ -1,3 +1,3 @@
 
       
-   Cloud Native Applications
\ No newline at end of file
+   Cloud Native Applications
\ No newline at end of file
diff --git a/single/spring-cloud-commons.html b/single/spring-cloud-commons.html
index 96d519aa..4a09ce5e 100644
--- a/single/spring-cloud-commons.html
+++ b/single/spring-cloud-commons.html
@@ -1,6 +1,6 @@
 
       
-   Cloud Native Applications

Cloud Native Applications


Cloud Native is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development. A related discipline is that of building 12-factor Apps in which development practices are aligned with delivery and operations goals, for instance by using declarative programming and management and monitoring. Spring Cloud facilitates these styles of development in a number of specific ways and the starting point is a set of features that all components in a distributed system either need or need easy access to when required.

Many of those features are covered by Spring Boot, which we build on in Spring Cloud. Some more are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons. Spring Cloud Context provides utilities and special services for the ApplicationContext of a Spring Cloud application (bootstrap context, encryption, refresh scope and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (eg. Spring Cloud Netflix vs. Spring Cloud Consul).

If you are getting an exception due to "Illegal key size" and you are using Sun’s JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. See the following links for more information:

Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).

[Note]Note

Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

1. Spring Cloud Context: Application Context Services

Spring Boot has an opinionated view of how to build an application + Cloud Native Applications

Cloud Native Applications


Cloud Native is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development. A related discipline is that of building 12-factor Apps in which development practices are aligned with delivery and operations goals, for instance by using declarative programming and management and monitoring. Spring Cloud facilitates these styles of development in a number of specific ways and the starting point is a set of features that all components in a distributed system either need or need easy access to when required.

Many of those features are covered by Spring Boot, which we build on in Spring Cloud. Some more are delivered by Spring Cloud as two libraries: Spring Cloud Context and Spring Cloud Commons. Spring Cloud Context provides utilities and special services for the ApplicationContext of a Spring Cloud application (bootstrap context, encryption, refresh scope and environment endpoints). Spring Cloud Commons is a set of abstractions and common classes used in different Spring Cloud implementations (eg. Spring Cloud Netflix vs. Spring Cloud Consul).

If you are getting an exception due to "Illegal key size" and you are using Sun’s JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. See the following links for more information:

Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).

[Note]Note

Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

1. Spring Cloud Context: Application Context Services

Spring Boot has an opinionated view of how to build an application with Spring: for instance it has conventional locations for common configuration file, and endpoints for common management and monitoring tasks. Spring Cloud builds on top of that and adds a few features that @@ -245,7 +245,7 @@ you would like to use for a given service.

[Note]Note

client in the above examples should be replaced with your Ribbon client’s -name.

2.4 Multiple RestTemplate objects

If you want a RestTemplate that is not load balanced, create a RestTemplate +name.

2.3.2 Multiple RestTemplate objects

If you want a RestTemplate that is not load balanced, create a RestTemplate bean and inject it as normal. To access the load balanced RestTemplate use the @LoadBalanced qualifier when you create your @Bean.

[Important]Important

Notice the @Primary annotation on the plain RestTemplate declaration in the example below, to disambiguate the unqualified @Autowired injection.

@Configuration
 public class MyConfiguration {
@@ -278,7 +278,21 @@ the @LoadBalanced qualifier when you create your public String doStuff() {
         return restTemplate.getForObject("http://example.com", String.class);
     }
-}
[Tip]Tip

If you see errors like java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89 try injecting RestOperations instead or setting spring.aop.proxyTargetClass=true.

2.5 Ignore Network Interfaces

Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".

application.yml.  +}

[Tip]Tip

If you see errors like java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89 try injecting RestOperations instead or setting spring.aop.proxyTargetClass=true.

2.4 Spring WebFlux WebClient as a Load Balancer Client

WebClient can be configured to use the LoadBalancerClient. A `LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath.

public class MyClass {
+    @Autowired
+    private LoadBalancerExchangeFilterFunction lbFunction;
+
+    public Mono<String> doOtherStuff() {
+        return WebClient.builder().baseUrl("http://stores")
+            .filter(lbFunction)
+            .build()
+            .get()
+            .uri("/stores")
+            .retrieve()
+            .bodyToMono(String.class);
+    }
+}

The URI needs to use a virtual host name (ie. service name, not a host name). +The LoadBalancerClient is used to create a full physical address.

2.5 Ignore Network Interfaces

Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".

application.yml. 

spring:
   cloud:
     inetutils:
diff --git a/spring-cloud-commons.html b/spring-cloud-commons.html
index e6fdbf4f..cc8922e5 100644
--- a/spring-cloud-commons.html
+++ b/spring-cloud-commons.html
@@ -90,7 +90,7 @@ $(addBlockSwitches);
 
-

1.3.1.BUILD-SNAPSHOT

+

2.0.0.BUILD-SNAPSHOT

diff --git a/spring-cloud-commons.xml b/spring-cloud-commons.xml index 4873e73e..99021688 100644 --- a/spring-cloud-commons.xml +++ b/spring-cloud-commons.xml @@ -432,7 +432,6 @@ public class MyConfiguration { name. -
Multiple RestTemplate objects If you want a RestTemplate that is not load balanced, create a RestTemplate @@ -477,6 +476,27 @@ public class MyClass { If you see errors like java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89 try injecting RestOperations instead or setting spring.aop.proxyTargetClass=true.
+ +
+Spring WebFlux WebClient as a Load Balancer Client +WebClient can be configured to use the LoadBalancerClient. A `LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. +public class MyClass { + @Autowired + private LoadBalancerExchangeFilterFunction lbFunction; + + public Mono<String> doOtherStuff() { + return WebClient.builder().baseUrl("http://stores") + .filter(lbFunction) + .build() + .get() + .uri("/stores") + .retrieve() + .bodyToMono(String.class); + } +} +The URI needs to use a virtual host name (ie. service name, not a host name). +The LoadBalancerClient is used to create a full physical address. +
Ignore Network Interfaces Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".