Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2018-11-19 21:17:48 +00:00
parent 5da6bef5df
commit ed441b8325
6 changed files with 67 additions and 27 deletions
@@ -55,4 +55,4 @@ might result in a YAML document resembling the following:</p><pre class="program
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> password</span>: password
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">info</span>:
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> description</span>: Spring Cloud Samples
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> url</span>: https://github.com/spring-cloud-samples</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__router_and_filter_zuul.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi_retrying-failed-requests.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.&nbsp;Router and Filter: Zuul&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-netflix.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;10.&nbsp;Retrying Failed Requests</td></tr></table></div></body></html>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> url</span>: https://github.com/spring-cloud-samples</pre><p>To enable the health check request to accept all certificates when using HTTPs set <code class="literal">sidecar.accept-all-ssl-certificates</code> to `true.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__router_and_filter_zuul.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi_retrying-failed-requests.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.&nbsp;Router and Filter: Zuul&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-netflix.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;10.&nbsp;Retrying Failed Requests</td></tr></table></div></body></html>
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -6,11 +6,11 @@ No matter how you choose to create your HTTP requests, there is always a chance
When a request fails, you may want to have the request be retried automatically.
To do so when using Sping Cloud Netflix, you need to include <a class="link" href="https://github.com/spring-projects/spring-retry" target="_top">Spring Retry</a> on your application&#8217;s classpath.
When Spring Retry is present, load-balanced <code class="literal">RestTemplates</code>, Feign, and Zuul automatically retry any failed requests (assuming your configuration allows doing so).</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_backoff_policies" href="#_backoff_policies"></a>10.1&nbsp;BackOff Policies</h2></div></div></div><p>By default, no backoff policy is used when retrying requests.
If you would like to configure a backoff policy, you need to create a bean of type <code class="literal">LoadBalancedBackOffPolicyFactory</code>, which is used to create a <code class="literal">BackOffPolicy</code> for a given service, as shown in the following example:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Configuration</span></em>
If you would like to configure a backoff policy, you need to create a bean of type <code class="literal">LoadBalancedRetryFactory</code> and override the <code class="literal">createBackOffPolicy</code> method for a given service, as shown in the following example:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Configuration</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> MyConfiguration {
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
LoadBalancedBackOffPolicyFactory backOffPolicyFactory() {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> LoadBalancedBackOffPolicyFactory() {
LoadBalancedRetryFactory retryFactory() {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> LoadBalancedRetryFactory() {
<em><span class="hl-annotation" style="color: gray">@Override</span></em>
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> BackOffPolicy createBackOffPolicy(String service) {
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> ExponentialBackOffPolicy();
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+21 -3
View File
@@ -1614,6 +1614,23 @@ public class ZuulConfig {
<simpara>Use this filter carefully. The filter acts on the <literal>Location</literal> header of ALL <literal>3XX</literal> response codes, which may not be appropriate in all scenarios, such as when redirecting the user to an external URL.</simpara>
</caution>
</section>
<section xml:id="_enabling_cross_origin_requests">
<title>Enabling Cross Origin Requests</title>
<simpara>By default Zuul routes all Cross Origin requests (CORS) to the services. If you want instead Zuul to handle these requests it can be done by providing custom <literal>WebMvcConfigurer</literal> bean:</simpara>
<programlisting language="java" linenumbering="unnumbered">@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/path-1/**")
.allowedOrigins("http://allowed-origin.com")
.allowedMethods("GET", "POST");
}
};
}</programlisting>
<simpara>In the example above, we allow <literal>GET</literal> and <literal>POST</literal> methods from <literal><link xl:href="http://allowed-origin.com">http://allowed-origin.com</link></literal> to send cross-origin requests to the endpoints starting with <literal>path-1</literal>.
You can apply CORS configuration to a specific path pattern or globally for the whole application, using <literal>/**</literal> mapping.
You can customize properties: <literal>allowedOrigins</literal>,<literal>allowedMethods</literal>,<literal>allowedHeaders</literal>,<literal>exposedHeaders</literal>,<literal>allowCredentials</literal> and <literal>maxAge</literal> via this configuration.</simpara>
</section>
<section xml:id="_metrics">
<title>Metrics</title>
<simpara>Zuul will provide metrics under the Actuator metrics endpoint for any failures that might occur when routing requests.
@@ -1994,6 +2011,7 @@ might result in a YAML document resembling the following:</simpara>
info:
description: Spring Cloud Samples
url: https://github.com/spring-cloud-samples</programlisting>
<simpara>To enable the health check request to accept all certificates when using HTTPs set <literal>sidecar.accept-all-ssl-certificates</literal> to `true.</simpara>
</chapter>
<chapter xml:id="retrying-failed-requests">
<title>Retrying Failed Requests</title>
@@ -2006,12 +2024,12 @@ When Spring Retry is present, load-balanced <literal>RestTemplates</literal>, Fe
<section xml:id="_backoff_policies">
<title>BackOff Policies</title>
<simpara>By default, no backoff policy is used when retrying requests.
If you would like to configure a backoff policy, you need to create a bean of type <literal>LoadBalancedBackOffPolicyFactory</literal>, which is used to create a <literal>BackOffPolicy</literal> for a given service, as shown in the following example:</simpara>
If you would like to configure a backoff policy, you need to create a bean of type <literal>LoadBalancedRetryFactory</literal> and override the <literal>createBackOffPolicy</literal> method for a given service, as shown in the following example:</simpara>
<programlisting language="java" linenumbering="unnumbered">@Configuration
public class MyConfiguration {
@Bean
LoadBalancedBackOffPolicyFactory backOffPolicyFactory() {
return new LoadBalancedBackOffPolicyFactory() {
LoadBalancedRetryFactory retryFactory() {
return new LoadBalancedRetryFactory() {
@Override
public BackOffPolicy createBackOffPolicy(String service) {
return new ExponentialBackOffPolicy();