Merge remote-tracking branch 'origin/1.3.x'

This commit is contained in:
Ryan Baxter
2018-01-18 19:53:37 -05:00
5 changed files with 259 additions and 15 deletions

View File

@@ -458,7 +458,43 @@ public class MyConfiguration {
NOTE: `client` in the above examples should be replaced with your Ribbon client's
name.
==== Multiple RestTemplate objects
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.
[source,java,indent=0]
----
@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...
}
}};
}
};
}
}
----
=== 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