From d54989ab20d9e50e8f2e778bcdef1cccdc5f59b3 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Thu, 16 Nov 2017 17:46:40 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- ..._spring_cloud_commons_common_abstractions.html | 15 ++++++++++++++- single/spring-cloud-commons.html | 15 ++++++++++++++- spring-cloud-commons.xml | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/multi/multi__spring_cloud_commons_common_abstractions.html b/multi/multi__spring_cloud_commons_common_abstractions.html index d0fb6220..c03f73a3 100644 --- a/multi/multi__spring_cloud_commons_common_abstractions.html +++ b/multi/multi__spring_cloud_commons_common_abstractions.html @@ -44,7 +44,20 @@ you can set spring.cloud.loadbalancer.retry.enabled=false< The properties you can use are client.ribbon.MaxAutoRetries, client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations. See the Ribbon documentation -for a description of what there properties do.

[Note]Note

client in the above examples should be replaced with your Ribbon client’s +for a description of what there properties do.

If you would like to implement a BackOffPolicy in your retries you will need to +create a bean of type LoadBalancedBackOffPolicyFactory, and return the BackOffPolicy +you would like to use for a given service.

@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedBackOffPolicyFactory backOffPolciyFactory() {
+        return new LoadBalancedBackOffPolicyFactory() {
+            @Override
+            public BackOffPolicy createBackOffPolicy(String service) {
+        		return new ExponentialBackOffPolicy();
+        	}
+        };
+    }
+}
[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 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
diff --git a/single/spring-cloud-commons.html b/single/spring-cloud-commons.html
index 20729e6a..96d519aa 100644
--- a/single/spring-cloud-commons.html
+++ b/single/spring-cloud-commons.html
@@ -231,7 +231,20 @@ you can set spring.cloud.loadbalancer.retry.enabled=false<
 The properties you can use are client.ribbon.MaxAutoRetries,
 client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations.
 See the Ribbon documentation
-for a description of what there properties do.

[Note]Note

client in the above examples should be replaced with your Ribbon client’s +for a description of what there properties do.

If you would like to implement a BackOffPolicy in your retries you will need to +create a bean of type LoadBalancedBackOffPolicyFactory, and return the BackOffPolicy +you would like to use for a given service.

@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedBackOffPolicyFactory backOffPolciyFactory() {
+        return new LoadBalancedBackOffPolicyFactory() {
+            @Override
+            public BackOffPolicy createBackOffPolicy(String service) {
+        		return new ExponentialBackOffPolicy();
+        	}
+        };
+    }
+}
[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 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
diff --git a/spring-cloud-commons.xml b/spring-cloud-commons.xml
index 129ea7fa..cb4c2949 100644
--- a/spring-cloud-commons.xml
+++ b/spring-cloud-commons.xml
@@ -412,6 +412,21 @@ The properties you can use are client.ribbon.MaxAutoRetries,
 client.ribbon.MaxAutoRetriesNextServer, and client.ribbon.OkToRetryOnAllOperations.
 See the Ribbon documentation
 for a description of what there properties do.
+If you would like to implement a BackOffPolicy in your retries you will need to
+create a bean of type LoadBalancedBackOffPolicyFactory, and return the BackOffPolicy
+you would like to use for a given service.
+@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedBackOffPolicyFactory backOffPolciyFactory() {
+        return new LoadBalancedBackOffPolicyFactory() {
+            @Override
+            public BackOffPolicy createBackOffPolicy(String service) {
+        		return new ExponentialBackOffPolicy();
+        	}
+        };
+    }
+}
 
 client in the above examples should be replaced with your Ribbon client’s
 name.