Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2018-09-17 20:20:02 +00:00
parent 39c1fe4090
commit 52586d785e
4 changed files with 65 additions and 4 deletions

View File

@@ -38,7 +38,23 @@
consul:
discovery:
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}</pre><p>
</p><p>With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the <code class="literal">vcap.application.instance_id</code> will be populated automatically in a Spring Boot application, so the random value will not be needed.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_looking_up_services" href="#_looking_up_services"></a>3.4&nbsp;Looking up services</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_using_ribbon" href="#_using_ribbon"></a>3.4.1&nbsp;Using Ribbon</h3></div></div></div><p>Spring Cloud has support for <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign" target="_top">Feign</a> (a REST client builder) and also <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon" target="_top">Spring <code class="literal">RestTemplate</code></a>
</p><p>With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the <code class="literal">vcap.application.instance_id</code> will be populated automatically in a Spring Boot application, so the random value will not be needed.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_applying_headers_to_health_check_requests" href="#_applying_headers_to_health_check_requests"></a>3.3.3&nbsp;Applying Headers to Health Check Requests</h3></div></div></div><p>Headers can be applied to health check requests. For example, if you&#8217;re trying to register a <a class="link" href="https://cloud.spring.io/spring-cloud-config/" target="_top">Spring Cloud Config</a> server that uses <a class="link" href="https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#vault-backend" target="_top">Vault Backend</a>:</p><p><b>application.yml.&nbsp;</b>
</p><pre class="screen">spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token: 6442e58b-d1ea-182e-cfa5-cf9cddef0722</pre><p>
</p><p>According to the HTTP standard, each header can have more than one values, in which case, an array can be supplied:</p><p><b>application.yml.&nbsp;</b>
</p><pre class="screen">spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token:
- "6442e58b-d1ea-182e-cfa5-cf9cddef0722"
- "Some other value"</pre><p>
</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_looking_up_services" href="#_looking_up_services"></a>3.4&nbsp;Looking up services</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_using_ribbon" href="#_using_ribbon"></a>3.4.1&nbsp;Using Ribbon</h3></div></div></div><p>Spring Cloud has support for <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign" target="_top">Feign</a> (a REST client builder) and also <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon" target="_top">Spring <code class="literal">RestTemplate</code></a>
for looking up services using the logical service names/ids instead of physical URLs. Both Feign and the discovery-aware RestTemplate utilize <a class="link" href="http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#spring-cloud-ribbon" target="_top">Ribbon</a> for client-side load balancing.</p><p>If you want to access service STORES using the RestTemplate simply declare:</p><pre class="screen">@LoadBalanced
@Bean
public RestTemplate loadbalancedRestTemplate() {

View File

@@ -1,3 +1,3 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring Cloud Consul</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-consul.html" title="Spring Cloud Consul"><link rel="next" href="multi_pr01.html" title=""></head><body class="firstpage" bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Spring Cloud Consul</th></tr><tr><td width="20%" align="left">&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi_pr01.html">Next</a></td></tr></table><hr></div><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Consul</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="multi_pr01.html"></a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-install.html">1. Install Consul</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-agent.html">2. Consul Agent</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-discovery.html">3. Service Discovery with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_how_to_activate">3.1. How to activate</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_registering_with_consul">3.2. Registering with Consul</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_http_health_check">3.3. HTTP Health Check</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_metadata_and_consul_tags">3.3.1. Metadata and Consul tags</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_making_the_consul_instance_id_unique">3.3.2. Making the Consul Instance ID Unique</a></span></dt></dl></dd><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_looking_up_services">3.4. Looking up services</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_using_ribbon">3.4.1. Using Ribbon</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_using_the_discoveryclient">3.4.2. Using the DiscoveryClient</a></span></dt></dl></dd><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_consul_catalog_watch">3.5. Consul Catalog Watch</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-config.html">4. Distributed Configuration with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#_how_to_activate_2">4.1. How to activate</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#_customizing">4.2. Customizing</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-watch">4.3. Config Watch</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-format">4.4. YAML or Properties with Config</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-git2consul">4.5. git2consul with Config</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-failfast">4.6. Fail Fast</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-retry.html">5. Consul Retry</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-bus.html">6. Spring Cloud Bus with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-bus.html#_how_to_activate_3">6.1. How to activate</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-hystrix.html">7. Circuit Breaker with Hystrix</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-turbine.html">8. Hystrix metrics aggregation with Turbine and Consul</a></span></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi_pr01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>
<title>Spring Cloud Consul</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud-consul.html" title="Spring Cloud Consul"><link rel="next" href="multi_pr01.html" title=""></head><body class="firstpage" bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Spring Cloud Consul</th></tr><tr><td width="20%" align="left">&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi_pr01.html">Next</a></td></tr></table><hr></div><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Consul</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="multi_pr01.html"></a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-install.html">1. Install Consul</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-agent.html">2. Consul Agent</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-discovery.html">3. Service Discovery with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_how_to_activate">3.1. How to activate</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_registering_with_consul">3.2. Registering with Consul</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_http_health_check">3.3. HTTP Health Check</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_metadata_and_consul_tags">3.3.1. Metadata and Consul tags</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_making_the_consul_instance_id_unique">3.3.2. Making the Consul Instance ID Unique</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_applying_headers_to_health_check_requests">3.3.3. Applying Headers to Health Check Requests</a></span></dt></dl></dd><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_looking_up_services">3.4. Looking up services</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_using_ribbon">3.4.1. Using Ribbon</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_using_the_discoveryclient">3.4.2. Using the DiscoveryClient</a></span></dt></dl></dd><dt><span class="section"><a href="multi_spring-cloud-consul-discovery.html#_consul_catalog_watch">3.5. Consul Catalog Watch</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-config.html">4. Distributed Configuration with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#_how_to_activate_2">4.1. How to activate</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#_customizing">4.2. Customizing</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-watch">4.3. Config Watch</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-format">4.4. YAML or Properties with Config</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-config-git2consul">4.5. git2consul with Config</a></span></dt><dt><span class="section"><a href="multi_spring-cloud-consul-config.html#spring-cloud-consul-failfast">4.6. Fail Fast</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-retry.html">5. Consul Retry</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-bus.html">6. Spring Cloud Bus with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="multi_spring-cloud-consul-bus.html#_how_to_activate_3">6.1. How to activate</a></span></dt></dl></dd><dt><span class="chapter"><a href="multi_spring-cloud-consul-hystrix.html">7. Circuit Breaker with Hystrix</a></span></dt><dt><span class="chapter"><a href="multi_spring-cloud-consul-turbine.html">8. Hystrix metrics aggregation with Turbine and Consul</a></span></dt></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi_pr01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right" valign="top">&nbsp;</td></tr></table></div></body></html>

View File

@@ -1,6 +1,6 @@
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring Cloud Consul</title><link rel="stylesheet" type="text/css" href="css/manual-singlepage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Consul</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="#d0e9"></a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-install">1. Install Consul</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-agent">2. Consul Agent</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-discovery">3. Service Discovery with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate">3.1. How to activate</a></span></dt><dt><span class="section"><a href="#_registering_with_consul">3.2. Registering with Consul</a></span></dt><dt><span class="section"><a href="#_http_health_check">3.3. HTTP Health Check</a></span></dt><dd><dl><dt><span class="section"><a href="#_metadata_and_consul_tags">3.3.1. Metadata and Consul tags</a></span></dt><dt><span class="section"><a href="#_making_the_consul_instance_id_unique">3.3.2. Making the Consul Instance ID Unique</a></span></dt></dl></dd><dt><span class="section"><a href="#_looking_up_services">3.4. Looking up services</a></span></dt><dd><dl><dt><span class="section"><a href="#_using_ribbon">3.4.1. Using Ribbon</a></span></dt><dt><span class="section"><a href="#_using_the_discoveryclient">3.4.2. Using the DiscoveryClient</a></span></dt></dl></dd><dt><span class="section"><a href="#_consul_catalog_watch">3.5. Consul Catalog Watch</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-config">4. Distributed Configuration with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate_2">4.1. How to activate</a></span></dt><dt><span class="section"><a href="#_customizing">4.2. Customizing</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-watch">4.3. Config Watch</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-format">4.4. YAML or Properties with Config</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-git2consul">4.5. git2consul with Config</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-failfast">4.6. Fail Fast</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-retry">5. Consul Retry</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-bus">6. Spring Cloud Bus with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate_3">6.1. How to activate</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-hystrix">7. Circuit Breaker with Hystrix</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-turbine">8. Hystrix metrics aggregation with Turbine and Consul</a></span></dt></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="d0e9" href="#d0e9"></a></h1></div></div></div><p><span class="strong"><strong>2.1.0.BUILD-SNAPSHOT</strong></span></p><p>This project provides Consul integrations for Spring Boot apps through autoconfiguration
<title>Spring Cloud Consul</title><link rel="stylesheet" type="text/css" href="css/manual-singlepage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="d0e3"></a>Spring Cloud Consul</h1></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="preface"><a href="#d0e9"></a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-install">1. Install Consul</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-agent">2. Consul Agent</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-discovery">3. Service Discovery with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate">3.1. How to activate</a></span></dt><dt><span class="section"><a href="#_registering_with_consul">3.2. Registering with Consul</a></span></dt><dt><span class="section"><a href="#_http_health_check">3.3. HTTP Health Check</a></span></dt><dd><dl><dt><span class="section"><a href="#_metadata_and_consul_tags">3.3.1. Metadata and Consul tags</a></span></dt><dt><span class="section"><a href="#_making_the_consul_instance_id_unique">3.3.2. Making the Consul Instance ID Unique</a></span></dt><dt><span class="section"><a href="#_applying_headers_to_health_check_requests">3.3.3. Applying Headers to Health Check Requests</a></span></dt></dl></dd><dt><span class="section"><a href="#_looking_up_services">3.4. Looking up services</a></span></dt><dd><dl><dt><span class="section"><a href="#_using_ribbon">3.4.1. Using Ribbon</a></span></dt><dt><span class="section"><a href="#_using_the_discoveryclient">3.4.2. Using the DiscoveryClient</a></span></dt></dl></dd><dt><span class="section"><a href="#_consul_catalog_watch">3.5. Consul Catalog Watch</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-config">4. Distributed Configuration with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate_2">4.1. How to activate</a></span></dt><dt><span class="section"><a href="#_customizing">4.2. Customizing</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-watch">4.3. Config Watch</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-format">4.4. YAML or Properties with Config</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-config-git2consul">4.5. git2consul with Config</a></span></dt><dt><span class="section"><a href="#spring-cloud-consul-failfast">4.6. Fail Fast</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-retry">5. Consul Retry</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-bus">6. Spring Cloud Bus with Consul</a></span></dt><dd><dl><dt><span class="section"><a href="#_how_to_activate_3">6.1. How to activate</a></span></dt></dl></dd><dt><span class="chapter"><a href="#spring-cloud-consul-hystrix">7. Circuit Breaker with Hystrix</a></span></dt><dt><span class="chapter"><a href="#spring-cloud-consul-turbine">8. Hystrix metrics aggregation with Turbine and Consul</a></span></dt></dl></div><div class="preface"><div class="titlepage"><div><div><h1 class="title"><a name="d0e9" href="#d0e9"></a></h1></div></div></div><p><span class="strong"><strong>2.1.0.BUILD-SNAPSHOT</strong></span></p><p>This project provides Consul integrations for Spring Boot apps through autoconfiguration
and binding to the Spring Environment and other Spring programming model idioms. With a few
simple annotations you can quickly enable and configure the common patterns inside your
application and build large distributed systems with Consul based components. The
@@ -44,7 +44,23 @@ Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon), Circuit Brea
consul:
discovery:
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}</pre><p>
</p><p>With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the <code class="literal">vcap.application.instance_id</code> will be populated automatically in a Spring Boot application, so the random value will not be needed.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_looking_up_services" href="#_looking_up_services"></a>3.4&nbsp;Looking up services</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_using_ribbon" href="#_using_ribbon"></a>3.4.1&nbsp;Using Ribbon</h3></div></div></div><p>Spring Cloud has support for <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign" target="_top">Feign</a> (a REST client builder) and also <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon" target="_top">Spring <code class="literal">RestTemplate</code></a>
</p><p>With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the <code class="literal">vcap.application.instance_id</code> will be populated automatically in a Spring Boot application, so the random value will not be needed.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_applying_headers_to_health_check_requests" href="#_applying_headers_to_health_check_requests"></a>3.3.3&nbsp;Applying Headers to Health Check Requests</h3></div></div></div><p>Headers can be applied to health check requests. For example, if you&#8217;re trying to register a <a class="link" href="https://cloud.spring.io/spring-cloud-config/" target="_top">Spring Cloud Config</a> server that uses <a class="link" href="https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#vault-backend" target="_top">Vault Backend</a>:</p><p><b>application.yml.&nbsp;</b>
</p><pre class="screen">spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token: 6442e58b-d1ea-182e-cfa5-cf9cddef0722</pre><p>
</p><p>According to the HTTP standard, each header can have more than one values, in which case, an array can be supplied:</p><p><b>application.yml.&nbsp;</b>
</p><pre class="screen">spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token:
- "6442e58b-d1ea-182e-cfa5-cf9cddef0722"
- "Some other value"</pre><p>
</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_looking_up_services" href="#_looking_up_services"></a>3.4&nbsp;Looking up services</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_using_ribbon" href="#_using_ribbon"></a>3.4.1&nbsp;Using Ribbon</h3></div></div></div><p>Spring Cloud has support for <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign" target="_top">Feign</a> (a REST client builder) and also <a class="link" href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-ribbon" target="_top">Spring <code class="literal">RestTemplate</code></a>
for looking up services using the logical service names/ids instead of physical URLs. Both Feign and the discovery-aware RestTemplate utilize <a class="link" href="http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#spring-cloud-ribbon" target="_top">Ribbon</a> for client-side load balancing.</p><p>If you want to access service STORES using the RestTemplate simply declare:</p><pre class="screen">@LoadBalanced
@Bean
public RestTemplate loadbalancedRestTemplate() {

View File

@@ -115,6 +115,35 @@ public class Application {
</formalpara>
<simpara>With this metadata, and multiple service instances deployed on localhost, the random value will kick in there to make the instance unique. In Cloudfoundry the <literal>vcap.application.instance_id</literal> will be populated automatically in a Spring Boot application, so the random value will not be needed.</simpara>
</section>
<section xml:id="_applying_headers_to_health_check_requests">
<title>Applying Headers to Health Check Requests</title>
<simpara>Headers can be applied to health check requests. For example, if you&#8217;re trying to register a <link xl:href="https://cloud.spring.io/spring-cloud-config/">Spring Cloud Config</link> server that uses <link xl:href="https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#vault-backend">Vault Backend</link>:</simpara>
<formalpara>
<title>application.yml</title>
<para>
<screen>spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token: 6442e58b-d1ea-182e-cfa5-cf9cddef0722</screen>
</para>
</formalpara>
<simpara>According to the HTTP standard, each header can have more than one values, in which case, an array can be supplied:</simpara>
<formalpara>
<title>application.yml</title>
<para>
<screen>spring:
cloud:
consul:
discovery:
health-check-headers:
X-Config-Token:
- "6442e58b-d1ea-182e-cfa5-cf9cddef0722"
- "Some other value"</screen>
</para>
</formalpara>
</section>
</section>
<section xml:id="_looking_up_services">
<title>Looking up services</title>