From bf766d539ed553e203c64f457d27327e401b95a9 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Wed, 7 Feb 2018 18:30:50 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- .../multi_spring-cloud-zookeeper-config.html | 2 +- ...i_spring-cloud-zookeeper-dependencies.html | 10 +++---- ...ng-cloud-zookeeper-dependency-watcher.html | 4 +-- ...ulti_spring-cloud-zookeeper-discovery.html | 2 +- ...ring-cloud-zookeeper-service-registry.html | 4 +-- single/spring-cloud-zookeeper.html | 22 +++++++-------- spring-cloud-zookeeper.xml | 28 +++++++++---------- 7 files changed, 33 insertions(+), 39 deletions(-) diff --git a/multi/multi_spring-cloud-zookeeper-config.html b/multi/multi_spring-cloud-zookeeper-config.html index ce984c78..42429425 100644 --- a/multi/multi_spring-cloud-zookeeper-config.html +++ b/multi/multi_spring-cloud-zookeeper-config.html @@ -4,7 +4,7 @@ config/testApp config/application,dev config/application

The most specific property source is at the top, with the least specific at the bottom. Properties is the config/application namespace are applicable to all applications using zookeeper for configuration. Properties in the config/testApp namespace are only available to the instances of the service named "testApp".

Configuration is currently read on startup of the application. Sending a HTTP POST to /refresh will cause the configuration to be reloaded. Watching the configuration namespace (which Zookeeper supports) is not currently implemented, but will be a future addition to this project.

7.1 How to activate

Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-config will enable auto-configuration that will setup Spring Cloud Zookeeper Config.

7.2 Customizing

Zookeeper Config may be customized using the following properties:

bootstrap.yml.  -

spring:
+

spring:
   cloud:
     zookeeper:
       config:
diff --git a/multi/multi_spring-cloud-zookeeper-dependencies.html b/multi/multi_spring-cloud-zookeeper-dependencies.html
index a6989b93..b7923674 100644
--- a/multi/multi_spring-cloud-zookeeper-dependencies.html
+++ b/multi/multi_spring-cloud-zookeeper-dependencies.html
@@ -3,7 +3,7 @@
    5. Zookeeper Dependencies

5. Zookeeper Dependencies

5.1 Using the Zookeeper Dependencies

Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application as properties. As dependencies you can understand other applications that are registered in Zookeeper and which you would like to call via Feign (a REST client builder) and also Spring RestTemplate.

You can also benefit from the Zookeeper Dependency Watchers functionality that lets you control and monitor what is the state of your dependencies and decide what to do with that.

5.2 How to activate Zookeeper Dependencies

  • Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-discovery will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.
  • If you have to have the spring.cloud.zookeeper.dependencies section properly set up - check the subsequent section for more details then the feature is active
  • You can have the dependencies turned off even if you’ve provided the dependencies in your properties. Just set the property spring.cloud.zookeeper.dependency.enabled to false (defaults to true).

5.3 Setting up Zookeeper Dependencies

Let’s take a closer look at an example of dependencies representation:

application.yml.  -

spring.application.name: yourServiceName
+

spring.application.name: yourServiceName
 spring.cloud.zookeeper:
   dependencies:
     newsletter:
@@ -25,16 +25,16 @@ spring.cloud.zookeeper:
       version: v1
       required: true

Let’s now go through each part of the dependency one by one. The root property name is spring.cloud.zookeeper.dependencies.

5.3.1 Aliases

Below the root property you have to represent each dependency has by an alias due to the constraints of Ribbon (the application id has to be placed in the URL -thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate.

In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be:

@FeignClient("newsletter")
-public interface NewsletterService {
-        @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
+thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate.

In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be:

@FeignClient("newsletter")
+public interface NewsletterService {
+        @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
         String getNewsletters();
 }

5.3.2 Path

Represented by path yaml property.

Path is the path under which the dependency is registered under Zookeeper. Like presented before Ribbon operates on URLs thus this path is not compliant with its requirement. That is why Spring Cloud Zookeeper maps the alias to the proper path.

5.3.3 Load balancer type

Represented by loadBalancerType yaml property.

If you know what kind of load balancing strategy has to be applied when calling this particular dependency then you can provide it in the yaml file and it will be automatically applied. You can choose one of the following load balancing strategies

  • STICKY - once chosen the instance will always be called
  • RANDOM - picks an instance randomly
  • ROUND_ROBIN - iterates over instances over and over again

5.3.4 Content-Type template and version

Represented by contentTypeTemplate and version yaml property.

If you version your api via the Content-Type header then you don’t want to add this header to each of your requests. Also if you want to call a new version of the API you don’t want to roam around your code to bump up the API version. That’s why you can provide a contentTypeTemplate with a special $version placeholder. That placeholder will be filled by the value of the version yaml property. Let’s take a look at an example.

Having the following contentTypeTemplate:

application/vnd.newsletter.$version+json

and the following version:

v1

Will result in setting up of a Content-Type header for each request:

application/vnd.newsletter.v1+json

5.3.5 Default headers

Represented by headers map in yaml

Sometimes each call to a dependency requires setting up of some default headers. In order not to do that in code you can set them up in the yaml file. -Having the following headers section:

headers:
+Having the following headers section:

headers:
     Accept:
         - text/html
         - application/xhtml+xml
diff --git a/multi/multi_spring-cloud-zookeeper-dependency-watcher.html b/multi/multi_spring-cloud-zookeeper-dependency-watcher.html
index 3ea1f91c..ed00ff8a 100644
--- a/multi/multi_spring-cloud-zookeeper-dependency-watcher.html
+++ b/multi/multi_spring-cloud-zookeeper-dependency-watcher.html
@@ -2,7 +2,7 @@
       
    6. Spring Cloud Zookeeper Dependency Watcher

6. Spring Cloud Zookeeper Dependency Watcher

The Dependency Watcher mechanism allows you to register listeners to your dependencies. The functionality is in fact an implementation of the Observator pattern. When a dependency changes its state (UP or DOWN) then some custom logic can be applied.

6.1 How to activate

Spring Cloud Zookeeper Dependencies functionality needs to be enabled to profit from Dependency Watcher mechanism.

6.2 Registering a listener

In order to register a listener you have to implement an interface org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener and register it as a bean. -The interface gives you one method:

    void stateChanged(String dependencyName, DependencyState newState);

If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information +The interface gives you one method:

void stateChanged(String dependencyName, DependencyState newState);

If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information whether your dependency has changed to CONNECTED or DISCONNECTED.

6.3 Presence Checker

Bound with Dependency Watcher is the functionality called Presence Checker. It allows you to provide custom behaviour upon booting of your application to react accordingly to the state of your dependencies.

The default implementation of the abstract org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier class is the -org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier which works in the following way.

  • If the dependency is marked us required and it’s not in Zookeeper then upon booting your application will throw an exception and shutdown
  • If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level

The functionality can be overriden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier.

\ No newline at end of file +org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier which works in the following way.

  • If the dependency is marked us required and it’s not in Zookeeper then upon booting your application will throw an exception and shutdown
  • If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level

The functionality can be overridden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier.

\ No newline at end of file diff --git a/multi/multi_spring-cloud-zookeeper-discovery.html b/multi/multi_spring-cloud-zookeeper-discovery.html index 461b8978..052db725 100644 --- a/multi/multi_spring-cloud-zookeeper-discovery.html +++ b/multi/multi_spring-cloud-zookeeper-discovery.html @@ -14,7 +14,7 @@ } }

(i.e. utterly normal Spring Boot app). If Zookeeper is located somewhere other than localhost:2181, the configuration is required to locate the server. Example:

application.yml.  -

spring:
+

spring:
   cloud:
     zookeeper:
       connect-string: localhost:2181

diff --git a/multi/multi_spring-cloud-zookeeper-service-registry.html b/multi/multi_spring-cloud-zookeeper-service-registry.html index 6071f485..c94ef656 100644 --- a/multi/multi_spring-cloud-zookeeper-service-registry.html +++ b/multi/multi_spring-cloud-zookeeper-service-registry.html @@ -11,6 +11,4 @@ .name("/a/b/c/d/anotherservice") .build(); this.serviceRegistry.register(registration); -}

4.1 Instance Status

Netflix Eureka supports having instances registered with the server that are OUT_OF_SERVICE and not returned as active service instances. This is very useful for behaviors such as blue/green deployments. The Curator Service Discovery recipe does not support this behavior. Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement OUT_OF_SERVICE by updating some specific metadata and then filtering on that metadata in the Ribbon ZookeeperServerList. The ZookeeperServerList filters out all non-null instance statuses that do not equal UP. If the instance status field is empty, it is considered UP for backwards compatibility. To change the status of an instance POST OUT_OF_SERVICE to the ServiceRegistry instance status actuator endpoint.

----
-$ echo -n OUT_OF_SERVICE | http POST http://localhost:8081/service-registry/instance-status
-----
NOTE: The above example uses the `http` command from https://httpie.org
\ No newline at end of file +}

4.1 Instance Status

Netflix Eureka supports having instances registered with the server that are OUT_OF_SERVICE and not returned as active service instances. This is very useful for behaviors such as blue/green deployments. The Curator Service Discovery recipe does not support this behavior. Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement OUT_OF_SERVICE by updating some specific metadata and then filtering on that metadata in the Ribbon ZookeeperServerList. The ZookeeperServerList filters out all non-null instance statuses that do not equal UP. If the instance status field is empty, it is considered UP for backwards compatibility. To change the status of an instance POST OUT_OF_SERVICE to the ServiceRegistry instance status actuator endpoint.

$ http POST http://localhost:8081/service-registry status=OUT_OF_SERVICE
NOTE: The above example uses the `http` command from https://httpie.org
\ No newline at end of file diff --git a/single/spring-cloud-zookeeper.html b/single/spring-cloud-zookeeper.html index 02066625..de77e3a8 100644 --- a/single/spring-cloud-zookeeper.html +++ b/single/spring-cloud-zookeeper.html @@ -20,7 +20,7 @@ Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon), Circuit Brea } }

(i.e. utterly normal Spring Boot app). If Zookeeper is located somewhere other than localhost:2181, the configuration is required to locate the server. Example:

application.yml.  -

spring:
+

spring:
   cloud:
     zookeeper:
       connect-string: localhost:2181

@@ -44,12 +44,10 @@ Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon), Circuit Brea .name("/a/b/c/d/anotherservice") .build(); this.serviceRegistry.register(registration); -}

4.1 Instance Status

Netflix Eureka supports having instances registered with the server that are OUT_OF_SERVICE and not returned as active service instances. This is very useful for behaviors such as blue/green deployments. The Curator Service Discovery recipe does not support this behavior. Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement OUT_OF_SERVICE by updating some specific metadata and then filtering on that metadata in the Ribbon ZookeeperServerList. The ZookeeperServerList filters out all non-null instance statuses that do not equal UP. If the instance status field is empty, it is considered UP for backwards compatibility. To change the status of an instance POST OUT_OF_SERVICE to the ServiceRegistry instance status actuator endpoint.

----
-$ echo -n OUT_OF_SERVICE | http POST http://localhost:8081/service-registry/instance-status
-----
NOTE: The above example uses the `http` command from https://httpie.org

5. Zookeeper Dependencies

5.1 Using the Zookeeper Dependencies

Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application as properties. As dependencies you can understand other applications that are registered +}

4.1 Instance Status

Netflix Eureka supports having instances registered with the server that are OUT_OF_SERVICE and not returned as active service instances. This is very useful for behaviors such as blue/green deployments. The Curator Service Discovery recipe does not support this behavior. Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement OUT_OF_SERVICE by updating some specific metadata and then filtering on that metadata in the Ribbon ZookeeperServerList. The ZookeeperServerList filters out all non-null instance statuses that do not equal UP. If the instance status field is empty, it is considered UP for backwards compatibility. To change the status of an instance POST OUT_OF_SERVICE to the ServiceRegistry instance status actuator endpoint.

$ http POST http://localhost:8081/service-registry status=OUT_OF_SERVICE
NOTE: The above example uses the `http` command from https://httpie.org

5. Zookeeper Dependencies

5.1 Using the Zookeeper Dependencies

Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application as properties. As dependencies you can understand other applications that are registered in Zookeeper and which you would like to call via Feign (a REST client builder) and also Spring RestTemplate.

You can also benefit from the Zookeeper Dependency Watchers functionality that lets you control and monitor what is the state of your dependencies and decide what to do with that.

5.2 How to activate Zookeeper Dependencies

  • Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-discovery will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.
  • If you have to have the spring.cloud.zookeeper.dependencies section properly set up - check the subsequent section for more details then the feature is active
  • You can have the dependencies turned off even if you’ve provided the dependencies in your properties. Just set the property spring.cloud.zookeeper.dependency.enabled to false (defaults to true).

5.3 Setting up Zookeeper Dependencies

Let’s take a closer look at an example of dependencies representation:

application.yml.  -

spring.application.name: yourServiceName
+

spring.application.name: yourServiceName
 spring.cloud.zookeeper:
   dependencies:
     newsletter:
@@ -71,16 +69,16 @@ spring.cloud.zookeeper:
       version: v1
       required: true

Let’s now go through each part of the dependency one by one. The root property name is spring.cloud.zookeeper.dependencies.

5.3.1 Aliases

Below the root property you have to represent each dependency has by an alias due to the constraints of Ribbon (the application id has to be placed in the URL -thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate.

In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be:

@FeignClient("newsletter")
-public interface NewsletterService {
-        @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
+thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate.

In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be:

@FeignClient("newsletter")
+public interface NewsletterService {
+        @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
         String getNewsletters();
 }

5.3.2 Path

Represented by path yaml property.

Path is the path under which the dependency is registered under Zookeeper. Like presented before Ribbon operates on URLs thus this path is not compliant with its requirement. That is why Spring Cloud Zookeeper maps the alias to the proper path.

5.3.3 Load balancer type

Represented by loadBalancerType yaml property.

If you know what kind of load balancing strategy has to be applied when calling this particular dependency then you can provide it in the yaml file and it will be automatically applied. You can choose one of the following load balancing strategies

  • STICKY - once chosen the instance will always be called
  • RANDOM - picks an instance randomly
  • ROUND_ROBIN - iterates over instances over and over again

5.3.4 Content-Type template and version

Represented by contentTypeTemplate and version yaml property.

If you version your api via the Content-Type header then you don’t want to add this header to each of your requests. Also if you want to call a new version of the API you don’t want to roam around your code to bump up the API version. That’s why you can provide a contentTypeTemplate with a special $version placeholder. That placeholder will be filled by the value of the version yaml property. Let’s take a look at an example.

Having the following contentTypeTemplate:

application/vnd.newsletter.$version+json

and the following version:

v1

Will result in setting up of a Content-Type header for each request:

application/vnd.newsletter.v1+json

5.3.5 Default headers

Represented by headers map in yaml

Sometimes each call to a dependency requires setting up of some default headers. In order not to do that in code you can set them up in the yaml file. -Having the following headers section:

headers:
+Having the following headers section:

headers:
     Accept:
         - text/html
         - application/xhtml+xml
@@ -93,14 +91,14 @@ actually be the alias that has to be resolved to a proper path in Zookeeper. Wit
 types with version as presented in the Dependency configuration. Without this setting of those two parameters will not be operational.
  • spring.cloud.zookeeper.dependency.resttemplate.enabled (enabled by default) - when enabled will modify the request headers of @LoadBalanced annotated RestTemplate so that it passes headers and content type with version set in Dependency configuration. Wihtout this setting of those two parameters will not be operational.
  • 6. Spring Cloud Zookeeper Dependency Watcher

    The Dependency Watcher mechanism allows you to register listeners to your dependencies. The functionality is in fact an implementation of the Observator pattern. When a dependency changes its state (UP or DOWN) then some custom logic can be applied.

    6.1 How to activate

    Spring Cloud Zookeeper Dependencies functionality needs to be enabled to profit from Dependency Watcher mechanism.

    6.2 Registering a listener

    In order to register a listener you have to implement an interface org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener and register it as a bean. -The interface gives you one method:

        void stateChanged(String dependencyName, DependencyState newState);

    If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information +The interface gives you one method:

    void stateChanged(String dependencyName, DependencyState newState);

    If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information whether your dependency has changed to CONNECTED or DISCONNECTED.

    6.3 Presence Checker

    Bound with Dependency Watcher is the functionality called Presence Checker. It allows you to provide custom behaviour upon booting of your application to react accordingly to the state of your dependencies.

    The default implementation of the abstract org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier class is the -org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier which works in the following way.

    • If the dependency is marked us required and it’s not in Zookeeper then upon booting your application will throw an exception and shutdown
    • If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level

    The functionality can be overriden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier.

    7. Distributed Configuration with Zookeeper

    Zookeeper provides a hierarchical namespace that allows clients to store arbitrary data, such as configuration data. Spring Cloud Zookeeper Config is an alternative to the Config Server and Client. Configuration is loaded into the Spring Environment during the special "bootstrap" phase. Configuration is stored in the /config namespace by default. Multiple PropertySource instances are created based on the application’s name and the active profiles that mimicks the Spring Cloud Config order of resolving properties. For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:

    config/testApp,dev
    +org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier which works in the following way.

    • If the dependency is marked us required and it’s not in Zookeeper then upon booting your application will throw an exception and shutdown
    • If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level

    The functionality can be overridden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier.

    7. Distributed Configuration with Zookeeper

    Zookeeper provides a hierarchical namespace that allows clients to store arbitrary data, such as configuration data. Spring Cloud Zookeeper Config is an alternative to the Config Server and Client. Configuration is loaded into the Spring Environment during the special "bootstrap" phase. Configuration is stored in the /config namespace by default. Multiple PropertySource instances are created based on the application’s name and the active profiles that mimicks the Spring Cloud Config order of resolving properties. For example, an application with the name "testApp" and with the "dev" profile will have the following property sources created:

    config/testApp,dev
     config/testApp
     config/application,dev
     config/application

    The most specific property source is at the top, with the least specific at the bottom. Properties is the config/application namespace are applicable to all applications using zookeeper for configuration. Properties in the config/testApp namespace are only available to the instances of the service named "testApp".

    Configuration is currently read on startup of the application. Sending a HTTP POST to /refresh will cause the configuration to be reloaded. Watching the configuration namespace (which Zookeeper supports) is not currently implemented, but will be a future addition to this project.

    7.1 How to activate

    Including a dependency on org.springframework.cloud:spring-cloud-starter-zookeeper-config will enable auto-configuration that will setup Spring Cloud Zookeeper Config.

    7.2 Customizing

    Zookeeper Config may be customized using the following properties:

    bootstrap.yml.  -

    spring:
    +

    spring:
       cloud:
         zookeeper:
           config:
    diff --git a/spring-cloud-zookeeper.xml b/spring-cloud-zookeeper.xml
    index c03c6d43..1db622bd 100644
    --- a/spring-cloud-zookeeper.xml
    +++ b/spring-cloud-zookeeper.xml
    @@ -52,10 +52,10 @@ public class Application {
     
     application.yml
     
    -spring:
    +spring:
       cloud:
         zookeeper:
    -      connect-string: localhost:2181
    +      connect-string: localhost:2181
     
     
     
    @@ -108,9 +108,7 @@ public void registerThings() {
     
    Instance Status Netflix Eureka supports having instances registered with the server that are OUT_OF_SERVICE and not returned as active service instances. This is very useful for behaviors such as blue/green deployments. The Curator Service Discovery recipe does not support this behavior. Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement OUT_OF_SERVICE by updating some specific metadata and then filtering on that metadata in the Ribbon ZookeeperServerList. The ZookeeperServerList filters out all non-null instance statuses that do not equal UP. If the instance status field is empty, it is considered UP for backwards compatibility. To change the status of an instance POST OUT_OF_SERVICE to the ServiceRegistry instance status actuator endpoint. ----- -$ echo -n OUT_OF_SERVICE | http POST http://localhost:8081/service-registry/instance-status ----- +$ http POST http://localhost:8081/service-registry status=OUT_OF_SERVICE NOTE: The above example uses the `http` command from https://httpie.org
    @@ -143,7 +141,7 @@ and also spring.application.name: yourServiceName spring.cloud.zookeeper: dependencies: newsletter: @@ -163,7 +161,7 @@ spring.cloud.zookeeper: loadBalancerType: ROUND_ROBIN contentTypeTemplate: application/vnd.mailing.$version+json version: v1 - required: true + required: true Let’s now go through each part of the dependency one by one. The root property name is spring.cloud.zookeeper.dependencies. @@ -172,11 +170,11 @@ spring.cloud.zookeeper: Below the root property you have to represent each dependency has by an alias due to the constraints of Ribbon (the application id has to be placed in the URL thus you can’t pass any complex path like /foo/bar/name). The alias will be the name that you will use instead of serviceId for DiscoveryClient, Feign or RestTemplate. In the aforementioned examples the aliases are newsletter and mailing. Example of Feign usage with newsletter would be: -@FeignClient("newsletter") +@FeignClient("newsletter") public interface NewsletterService { @RequestMapping(method = RequestMethod.GET, value = "/newsletter") String getNewsletters(); -} +}
    Path @@ -219,12 +217,12 @@ roam around your code to bump up the API version. That’s why you can provi Represented by headers map in yaml Sometimes each call to a dependency requires setting up of some default headers. In order not to do that in code you can set them up in the yaml file. Having the following headers section: -headers: +headers: Accept: - text/html - application/xhtml+xml Cache-Control: - - no-cache + - no-cache Results in adding the Accept and Cache-Control headers with appropriate list of values in your HTTP request.
    @@ -295,7 +293,7 @@ its state (UP or DOWN) then some custom logic can be applied. Registering a listener In order to register a listener you have to implement an interface org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener and register it as a bean. The interface gives you one method: - void stateChanged(String dependencyName, DependencyState newState); +void stateChanged(String dependencyName, DependencyState newState); If you want to register a listener for a particular dependency then the dependencyName would be the discriminator for your concrete implementation. newState will provide you with information whether your dependency has changed to CONNECTED or DISCONNECTED.
    @@ -313,7 +311,7 @@ of your dependencies. If dependency is not required the org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker will log that application is missing at WARN level -The functionality can be overriden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier. +The functionality can be overridden since the DefaultDependencyPresenceOnStartupVerifier is registered only when there is no bean of DependencyPresenceOnStartupVerifier. @@ -335,14 +333,14 @@ config/application bootstrap.yml -spring: +spring: cloud: zookeeper: config: enabled: true root: configuration defaultContext: apps - profileSeparator: '::' + profileSeparator: '::'