From fbc4d81cd619e77dbcc24c7f70e52f14950ce48b Mon Sep 17 00:00:00 2001 From: buildmaster Date: Fri, 22 Dec 2017 15:33:27 +0000 Subject: [PATCH] Sync docs from 1.3.x to gh-pages --- ...ing_cloud_commons_common_abstractions.html | 31 ++++++++++++++++++- 1.3.x/single/spring-cloud-commons.html | 31 ++++++++++++++++++- 1.3.x/spring-cloud-commons.xml | 31 +++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/1.3.x/multi/multi__spring_cloud_commons_common_abstractions.html b/1.3.x/multi/multi__spring_cloud_commons_common_abstractions.html index c03f73a3..0d13046b 100644 --- a/1.3.x/multi/multi__spring_cloud_commons_common_abstractions.html +++ b/1.3.x/multi/multi__spring_cloud_commons_common_abstractions.html @@ -58,7 +58,36 @@ 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.

If you want to add one or more RetryListener to your retry you will need to +create a bean of type LoadBalancedRetryListenerFactory and return the RetryListener array +you would like to use for a given service.

@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedRetryListenerFactory retryListenerFactory() {
+        return new LoadBalancedRetryListenerFactory() {
+            @Override
+            public RetryListener[] createRetryListeners(String service) {
+                return new RetryListener[]{new RetryListener() {
+                    @Override
+                    public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
+                        //TODO Do you business...
+                        return true;
+                    }
+
+                    @Override
+                     public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+
+                    @Override
+                    public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+                }};
+            }
+        };
+    }
+}

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
 public class MyConfiguration {
diff --git a/1.3.x/single/spring-cloud-commons.html b/1.3.x/single/spring-cloud-commons.html
index 96d519aa..0892c77f 100644
--- a/1.3.x/single/spring-cloud-commons.html
+++ b/1.3.x/single/spring-cloud-commons.html
@@ -245,7 +245,36 @@ 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.

If you want to add one or more RetryListener to your retry you will need to +create a bean of type LoadBalancedRetryListenerFactory and return the RetryListener array +you would like to use for a given service.

@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedRetryListenerFactory retryListenerFactory() {
+        return new LoadBalancedRetryListenerFactory() {
+            @Override
+            public RetryListener[] createRetryListeners(String service) {
+                return new RetryListener[]{new RetryListener() {
+                    @Override
+                    public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
+                        //TODO Do you business...
+                        return true;
+                    }
+
+                    @Override
+                     public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+
+                    @Override
+                    public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+                }};
+            }
+        };
+    }
+}

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
 public class MyConfiguration {
diff --git a/1.3.x/spring-cloud-commons.xml b/1.3.x/spring-cloud-commons.xml
index 57949433..3a308522 100644
--- a/1.3.x/spring-cloud-commons.xml
+++ b/1.3.x/spring-cloud-commons.xml
@@ -431,6 +431,37 @@ public class MyConfiguration {
 client in the above examples should be replaced with your Ribbon client’s
 name.
 
+If you want to add one or more RetryListener to your retry you will need to
+create a bean of type LoadBalancedRetryListenerFactory and return the RetryListener array
+you would like to use for a given service.
+@Configuration
+public class MyConfiguration {
+    @Bean
+    LoadBalancedRetryListenerFactory retryListenerFactory() {
+        return new LoadBalancedRetryListenerFactory() {
+            @Override
+            public RetryListener[] createRetryListeners(String service) {
+                return new RetryListener[]{new RetryListener() {
+                    @Override
+                    public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
+                        //TODO Do you business...
+                        return true;
+                    }
+
+                    @Override
+                     public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+
+                    @Override
+                    public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
+                        //TODO Do you business...
+                    }
+                }};
+            }
+        };
+    }
+}