spring: - cloud: - inetutils: - ignoredInterfaces: - - docker0 - - veth.*-
diff --git a/spring-cloud.html b/spring-cloud.html index 290bb01..cbf1bd0 100644 --- a/spring-cloud.html +++ b/spring-cloud.html @@ -435,7 +435,6 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
Java 6 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
Java 7 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
Java 8 JCE Link http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).
|
- Note
- |
--Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at {githubmaster}/docs/src/main/asciidoc[github]. - | -
The bootstrap.yml (or .properties) location can be specified using
-spring.cloud.bootstrap.name (default "bootstrap") or
+
The bootstrap.yml (or .properties) location can be specified using
+`spring.cloud.bootstrap.name (default "bootstrap") or
spring.cloud.bootstrap.location (default empty), e.g. in System
properties. Those properties behave like the spring.config.*
variants with the same name, in fact they are used to set up the
@@ -998,23 +965,7 @@ classpath (Maven co-ordinates
the full strength JCE extensions in your JVM.
If you are getting an exception due to "Illegal key size" and you are using Sun’s JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. See the following links for more information:
-Extract files into JDK/jre/lib/security folder (whichever version of JRE/JDK x64/x86 you are using).
+include::jce.adoc
LoadBalancerClient bean
The URI needs to use a virtual host name (ie. service name, not a host name).
The Ribbon client is used to create a full physical address. See
-RibbonAutoConfiguration
+{github-code}/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[RibbonAutoConfiguration]
for details of how the RestTemplate is set up.
Qualifier:
-Sometimes it is useful to ignore certain named network interfaces so they can be excluded from Service Discovery registration (eg. running in a Docker container). A list of regular expressions can be set that will cause the desired network interfaces to be ignored. The following configuration will ignore the "docker0" interface and all interfaces that start with "veth".
-spring: - cloud: - inetutils: - ignoredInterfaces: - - docker0 - - veth.*-
Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
+Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
The server is a Spring Boot application so you can run it from your
-IDE instead if you prefer (the main class is
-ConfigServerApplication). Then try it out a client:
The server is a Spring Boot application so you can build the jar file
+and run that (java -jar …) or pull it down from a Maven
+repository. Then try it out as a client:
The default strategy for locating property sources is to clone a git
-repository (at spring.cloud.config.server.git.uri) and use it to
+repository (at "spring.cloud.config.server.git.uri") and use it to
initialize a mini SpringApplication. The mini-application’s
Environment is used to enumerate property sources and publish them
via a JSON endpoint.
where the "application" is injected as the spring.config.name in the
+
where the "application" is injected as the "spring.config.name" in the
SpringApplication (i.e. what is normally "application" in a regular
Spring Boot app), "profile" is an active profile (or comma-separated
list of properties), and "label" is an optional git label (defaults to
@@ -1189,12 +1128,12 @@ from a git repository (which must be provided):
spring:
+spring:
cloud:
config:
- server:
- git:
- uri: https://github.com/spring-cloud-samples/config-repo
+ server:
+ git:
+ uri: https://github.com/spring-cloud-samples/config-repo
@SpringBootApplication
+@Configuration
+@EnableAutoConfiguration
@RestController
public class Application {
@@ -1332,91 +1272,7 @@ the config server URL.
The Server provides an HTTP, resource-based API for external
configuration (name-value pairs, or equivalent YAML content). The
server is easily embeddable in a Spring Boot application using the
-@EnableConfigServer annotation. So this app is a config server:
-@SpringBootApplication
-@EnableConfigServer
-public class ConfigServer {
- public static void main(String[] args) {
- SpringApplication.run(ConfigServer.class, args);
- }
-}
-Like all Spring Boot apps it runs on port 8080 by default, but you
-can switch it to the conventional port 8888 in various ways. The
-easiest, which also sets a default configuration repository,
-is by launching it with spring.config.name=configserver (there
-is a configserver.yml in the Config Server jar). Another is
-to use your own application.properties, e.g.
server.port: 8888
-spring.cloud.config.server.git.uri: file://${user.home}/config-repo
-where ${user.home}/config-repo is a git repository containing
-YAML and properties files.
|
- Note
- |
-
-in Windows you need an extra "/" in the file URL if it is
-absolute with a drive prefix, e.g. file:///${user.home}/config-repo.
- |
-
|
- Tip
- |
-
-
-
-Here’s a recipe for creating the git repository in the example -above: -
-
-
-
-$ cd $HOME -$ mkdir config-repo -$ cd config-repo -$ git init . -$ echo info.foo: bar > application.properties -$ git add -A . -$ git commit -m "Add application.properties"- |
-
|
- Warning
- |
--using the local filesystem for your git repository is -intended for testing only. Use a server to host your -configuration repositories in production. - | -
@EnableConfigServer annotation.
Map).
spring:
+spring:
application:
name: foo
profiles:
- active: dev,mysql
+ active: dev,mysql
Spring Cloud Config Server supports a git repository URL with
-placeholders for the {application} and {profile} (and {label} if
-you need it, but remember that the label is applied as a git label
-anyway). So you can easily support a "one repo per application" policy
-using (for example):
Spring Cloud Config Server supports a single or multiple git +repositories:
spring:
- cloud:
- config:
- server:
- git:
- uri: https://github.com/myorg/{application}
-or a "one repo per profile" policy using a similar pattern but with
-{profile}.
There is also support for more complex requirements with pattern
-matching on the application and profile name. The pattern format is a
-comma-separated list of {application}/{profile} names with wildcards
-(where a pattern beginning with a wildcard may need to be
-quoted). Example:
spring:
+spring:
cloud:
config:
server:
@@ -1552,22 +1379,20 @@ quoted). Example:
repos:
simple: https://github.com/simple/config-repo
special:
- pattern: special*/dev*,*special*/dev*
+ pattern: pattern*,*pattern1*
uri: https://github.com/special/config-repo
local:
pattern: local*
- uri: file:/home/configsvc/config-repo
+ uri: file:/home/configsvc/config-repo
If {application}/{profile} does not match any of the patterns, it
-will use the default uri defined under
-"spring.cloud.config.server.git.uri". In the above example, for the
-"simple" repository, the pattern is simple/* (i.e. it only matches
-one application named "simple" in all profiles). The "local"
-repository matches all application names beginning with "local" in all
-profiles (the /* suffix is added automatically to any pattern that
-doesn’t have a profile matcher).
In the above example, if {application} does not match any of the
+patterns, it will use the default uri defined under
+"spring.cloud.config.server.git.uri". For the "simple" repository, the
+pattern is "simple" (i.e. it only matches one application named "simple").
+The pattern format is a comma-separated list of application names with
+wildcards (a pattern beginning with a wildcard may need to be quoted).
The pattern property in the repo is actually an array, so you can
-use a YAML array (or [0], [1], etc. suffixes in properties files)
-to bind to multiple patterns. You may need to do this if you are going
-to run apps with multiple profiles. Example:
spring:
- cloud:
- config:
- server:
- git:
- uri: https://github.com/spring-cloud-samples/config-repo
- repos:
- development:
- pattern:
- - */development
- - */staging
- uri: https://github.com/development/config-repo
- staging:
- pattern:
- - */qa
- - */production
- uri: https://github.com/staging/config-repo
-|
- Note
- |
-
-Spring Cloud will guess that a pattern containing a profile that
-doesn’t end in * implies that you actually want to match a list of
-profiles starting with this pattern (so */staging is a shortcut for
-["*/staging", "*/staging,*"]). This is common where you need to run
-apps in the "development" profile locally but also the "cloud" profile
-remotely, for instance.
- |
-
Every repository can also optionally store config files in
sub-directories, and patterns to search for those directories can be
specified as searchPaths. For example at the top level:
spring:
+spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
- searchPaths: foo,bar*
+ searchPaths: foo,bar*
spring:
+spring:
cloud:
config:
server:
@@ -1673,7 +1454,7 @@ at startup. For example at the top level:
uri: http://git/team-b/config-repo.git
team-c:
pattern: team-c-*
- uri: http://git/team-a/config-repo.git
+ uri: http://git/team-a/config-repo.git
spring:
+spring:
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
username: trolley
- password: strongpassword
+ password: strongpassword
~/.ssh)
and the uri points to an SSH location,
e.g. "git@github.com:configuration/cloud-configuration". The
repository is accessed using JGit, so any documentation you find on
-that should be applicable. HTTPS proxy settings can be set in
-~/.git/config or in the same way as for any other JVM process via
-system properties (-Dhttps.proxyHost and -Dhttps.proxyPort).
--Dhttps.proxyHost and -Dhttps.proxyPortThere is also a "native" profile in the Config Server that doesn’t use
Git, but just loads the config files from the local classpath or file
system (any static URL you want to point to with
-"spring.cloud.config.server.native.searchLocations"). To use the
-native profile just launch the Config Server with
+"spring.cloud.config.server.native.searchLocations"). To use the native
+profile just launch the Config Server with
"spring.profiles.active=native".
|
- Note
- |
-
-Remember to use the file: prefix for file resources (the
-default without a prefix is usually the classpath). Just as with any
-Spring Boot configuration you can embed ${}-style environment
-placeholders, but remember that absolute paths in Windows require an
-extra "/", e.g. file:///${user.home}/config-repo
- |
-
The default value of the searchLocations is identical to a
-local Spring Boot application (so [classpath:/, classpath:/config,
-file:./, file:./config]). This does not expose the
-application.properties from the server to all clients because any
-property sources present in the server are removed before being sent
-to the client.
+local Spring Boot application (so
+[classpath:/, classpath:/config, file:./, file:./config]) which will
+expose the application.properties from the server to all clients.
|
The search locations can contain placeholders for {application},
-{profile} and {label}. In this way you can segregate the
-directories in the path, and choose a strategy that makes sense for
-you (e.g. sub-directory per application, or sub-directory per
-profile).
If you don’t use placeholders in the search locations, this repository
-also appends the {label} parameter of the HTTP resource to a suffix
-on the search path, so properties files are loaded from each search
-location and a subdirectory with the same name as the label (the
-labelled properties take precedence in the Spring Environment). Thus
-the default behaviour with no placeholders is the same as adding a
-search location ending with /{label}/. For example `file:/tmp/config
-is the same as file:/tmp/config,file:/tmp/config/{label}
With file-based (i.e. git, svn and native) repositories, resources
-with file names in application* are shared between all client
-applications (so application.properties, application.yml,
-application-*.properties etc.). You can use resources with these
-file names to configure global defaults and have them overridden by
-application-specific files as necessary.
The #_property_overrides[property overrides] feature can also be used -for setting global defaults, and with placeholders applications are -allowed to override them locally.
-|
- Tip
- |
-
-With the "native" profile (local file system backend) it is
-recommended that you use an explicit search location that isn’t part
-of the server’s own configuration. Otherwise the application*
-resources in the default search locations are removed because they are
-part of the server.
- |
-
The Config Server has an "overrides" feature that allows the operator
-to provide configuration properties to all applications that cannot be
-accidentally changed by the application using the normal Spring Boot
-hooks. To declare overrides just add a map of name-value pairs to
-spring.cloud.config.server.overrides. For example
spring:
- cloud:
- config:
- server:
- foo: bar
-will cause all applications that are config clients to read foo=bar
-independent of their own configuration. (Of course an application can
-use the data in the Config Server in any way it likes, so overrides
-are not enforceable, but they do provide useful default behaviour if
-they are Spring Cloud Config clients.)
|
- Tip
- |
-
-Normal, Spring environment placeholders with "${}" can be escaped
-(and resolved on the client) by using backslash ("\") to escape the
-"$" or the "{", e.g. \${app.foo:bar} resolves to "bar" unless the
-app provides its own "app.foo". Note that in YAML you don’t need to
-escape the backslash itself, but in properties files you do, when you
-configure the overrides on the server.
- |
-
You can change the priority of all overrides in the client to be more -like default values, allowing applications to supply their own values -in environment variables or System properties, by setting the flag `
+This repository implementation maps the {label} parameter of the
+HTTP resource to a suffix on the search path, so properties files are
+loaded from each search location and a subdirectory with the same
+name as the label (the labelled properties take precedence in the
+Spring Environment).
spring:
+spring:
cloud:
config:
server:
@@ -1891,7 +1561,7 @@ along with custom profiles and custom labels, e.g.
label: mylabel
myservice-dev:
name: myservice
- profiles: development
+ profiles: development
If the remote property sources contain encrypted content +
If the remote property sources contain encryted content
(values starting with {cipher}) they will be decrypted before
sending to clients over HTTP. The main advantage of this set up is
that the property values don’t have to be in plain text when they are
@@ -1951,20 +1621,10 @@ instance:
spring:
+spring:
datasource:
username: dbuser
- password: '{cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ'
-Encrypted values in a .properties file must not be wrapped in quotes, otherwise the value will not be decrypted:
-spring.datasource.username: dbuser
-spring.datasource.password: {cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ
+ password: '{cipher}FKSAJDFGYOS8F7GLHAKERGFHLSAJ'
|
- Tip
- |
-
-If you are testing like this with curl, then use
---data-urlencode (instead of -d) or set an explicit Content-Type:
-text/plain to make sure curl encodes the data correctly when there
-are special characters ('+' is particularly tricky).
- |
-
Take the encrypted value and add the {cipher} prefix before you put
+
Take the encypted value and add the {cipher} prefix before you put
it in the YAML or properties file, and before you commit and push it
-to a remote, potentially insecure store.
The /encrypt and /decrypt endpoints also both accept paths of the
-form /*/{name}/{profiles} which can be used to control cryptography
-per application (name) and profile when clients call into the main
-Environment resource.
/encypt and /decrypt
+endpoints also both accept paths of the form /*/{name}/{profiles}
+which can be used to control cryptography per application (name)
+and profile when clients call into the main Environment resource.
To use a key in a file (e.g. an RSA public key for encryption) prepend +
To use a key in a file (e.g. an RSA public key for encyption) prepend the key value with "@" and provide the file path, e.g.
application.yml for the Config Server:
encrypt:
+encrypt:
keyStore:
location: classpath:/server.jks
password: letmein
alias: mytestkey
- secret: changeme
+ secret: changeme
foo:
- bar: `{cipher}{key:testkey}...`
+foo:
+ bar: `{cipher}{key:testkey}...`
Instead of using the Environment abstraction (or one of the
-alternative representations of it in YAML or properties format) your
-applications might need generic plain text configuration files,
-tailored to their environment. The Config Server provides these
-through an additional endpoint at /{name}/{profile}/{label}/{path}
-where "name", "profile" and "label" have the same meaning as the
-regular environment endpoint, but "path" is a file name
-(e.g. log.xml). The source files for this endpoint are located in
-the same way as for the environment endpoints: the same search path is
-used as for properties or YAML files, but instead of aggregating all
-matching resources, only the first one to match is returned.
After a resource is located, placeholders in the normal format
-(${…}) are resolved using the effective Environment for the
-application name, profile and label supplied. In this way the resource
-endpoint is tightly integrated with the environment
-endpoints. Example, if you have this layout for a GIT (or SVN)
-repository:
application.yml -nginx.conf-
where nginx.conf looks like this:
server {
- listen 80;
- server_name ${nginx.server.name};
-}
-and application.yml like this:
nginx:
- server:
- name: example.com
----
-spring:
- profiles: development
-nginx:
- server:
- name: develop.com
-then the /foo/default/master/nginx.conf resource looks like this:
server {
- listen 80;
- server_name example.com;
-}
-and /foo/development/master/nginx.conf like this:
server {
- listen 80;
- server_name develop.com;
-}
-|
- Note
- |
-
-just like the source files for environment configuration, the
-"profile" is used to resolve the file name, so if you want a
-profile-specific file then /*/development/*/logback.xml will be
-resolved by a file called logback-development.xml (in preference
-to logback.xml).
- |
-
The Config Server runs best as a standalone application, but if you
need to you can embed it in another application. Just use the
-@EnableConfigServer annotation. An optional property that can be
+@EnableConfigServer annotation and (optionally) set
+spring.cloud.config.server.prefix to a path prefix, e.g. "/config",
+to serve the resources under a prefix. The prefix should start but not
+end with a "/". It is applied to the @RequestMappings in the Config
+Server (i.e. underneath the Spring Boot prefixes server.servletPath
+and server.contextPath). Another optional property that can be
useful in this case is spring.cloud.config.server.bootstrap which is
a flag to indicate that the server should configure itself from its
own remote repository. The flag is off by default because it can delay
startup, but when embedded in another application it makes sense to
initialize the same way as any other application.
|
- Note
- |
-
-It should be obvious, but remember that if you use the bootstrap
-flag the config server will need to have its name and repository URI
-configured in bootstrap.yml.
- |
-
To change the location of the server endpoints you can (optionally)
-set spring.cloud.config.server.prefix, e.g. "/config", to serve the
-resources under a prefix. The prefix should start but not end with a
-"/". It is applied to the @RequestMappings in the Config Server
-(i.e. underneath the Spring Boot prefixes server.servletPath and
-server.contextPath).
If you want to read the configuration for an application directly from
-the backend repository (instead of from the config server) that’s
-basically an embedded config server with no endpoints. You can switch
-off the endpoints entirely if you don’t use the @EnableConfigServer
-annotation (just set spring.cloud.config.server.bootstrap=true).
Many source code repository providers (like Github, Gitlab or Bitbucket
-for instance) will notify you of changes in a repository through a
-webhook. You can configure the webhook via the provider’s user
-interface as a URL and a set of events in which you are
-interested. For instance
-Github
-will POST to the webhook with a JSON body containing a list of
-commits, and a header "X-Github-Event" equal to "push". If you add a
-dependency on the spring-cloud-config-monitor library and activate
-the Spring Cloud Bus in your Config Server, then a "/monitor" endpoint
-is enabled.
When the webhook is activated the Config Server will send a
-RefreshRemoteApplicationEvent targeted at the applications it thinks
-might have changed. The change detection can be strategized, but by
-default it just looks for changes in files that match the application
-name (e.g. "foo.properties" is targeted at the "foo" application, and
-"application.properties" is targeted at all applications). The strategy
-if you want to override the behaviour is PropertyPathNotificationExtractor
-which accepts the request headers and body as parameters and returns a list
-of file paths that changed.
The default configuration works out of the box with Github, Gitlab or
-Bitbucket. In addition to the JSON notifications from Github, Gitlab
-or Bitbucket you can trigger a change notification by POSTing to
-"/monitor" with a form-encoded body parameters path={name}. This will
-broadcast to applications matching the "{name}" pattern (can contain
-wildcards).
|
- Note
- |
-
-the RefreshRemoteApplicationEvent will only be transmitted if
-the spring-cloud-bus is activated in the Config Server and in the
-client application.
- |
-
|
- Note
- |
--the default configuration also detects filesystem changes in -local git repositories (the webhook is not used in that case but as -soon as you edit a config file a refresh will be broadcast). - | -
spring.cloud.config.failFast=true, and then you need to add
spring-retry and spring-boot-starter-aop to your classpath. The default
behaviour is to retry 6 times with an initial backoff interval of 1000ms and an
exponential multiplier of 1.1 for subsequent backoffs. You can configure these
-properties (and others) using spring.cloud.config.retry.* configuration properties.
+properties (and others) using spring.config.retry.* configuration properties.
|
- Note
- |
--If your app is running behind a proxy, and the SSL termination -is in the proxy (e.g. if you run in Cloud Foundry or other platforms -as a service) then you will need to ensure that the proxy "forwarded" -headers are intercepted and handled by the application. An embedded -Tomcat container in a Spring Boot app does this automatically if it -has explicit configuration for the 'X-Forwarded-\*` headers. A sign -that you got this wrong will be that the links rendered by your app to -itself will be wrong (the wrong host, port or protocol). - | -
By default, Eureka uses the client heartbeat to determine if a client is up. -Unless specified otherwise the Discovery Client will not propagate the -current health check status of the application per the Spring Boot Actuator. Which means -that after successful registration Eureka will always announce that the -application is in 'UP' state. This behaviour can be altered by enabling -Eureka health checks, which results in propagating application status -to Eureka. As a consequence every other application won’t be sending -traffic to application in state other then 'UP'.
-eureka: - client: - healthcheck: - enabled: true-
If you require more control over the health checks, you may consider
-implementing your own com.netflix.appinfo.HealthCheckHandler.
It’s worth spending a bit of time understanding how the Eureka metadata works, so you can use it in a way that makes sense in your platform. There is standard metadata for things like hostname, IP address, port numbers, status page and health check. These are published in the service registry and used by clients to contact the services in a straightforward way. Additional metadata can be added to the instance registration in the eureka.instance.metadataMap, and this will be accessible in the remote clients, but in general will not change the behaviour of the client, unless it is made aware of the meaning of the metadata. There are a couple of special cases described below where Spring Cloud already assigns meaning to the metadata map.
com.netflix.appinfo.HealthCheckHandler.
Cloudfoundry has a global router so that all instances of the same app have the same hostname (it’s the same in other PaaS solutions with a similar architecture). This isn’t necessarily a barrier to using Eureka, but if you use the router (recommended, or even mandatory depending on the way your platform was set up), you need to explicitly set the hostname and port numbers (secure or non-secure) so that they use the router. You might also want to use instance metadata so you can distinguish between the instances on the client (e.g. in a custom load balancer). By default, the eureka.instance.instanceId is vcap.application.instance_id. For example:
Cloudfoundry has a global router so that all instances of the same app have the same hostname (it’s the same in other PaaS solutions with a similar architecture). This isn’t necessarily a barrier to using Eureka, but if you use the router (recommended, or even mandatory depending on the way your platform was set up), you need to explicitly set the hostname and port numbers (secure or non-secure) so that they use the router. You might also want to use instance metadata so you can distinguish between the instances on the client (e.g. in a custom load balancer). For example:
com.netflix.appinfo.HealthCheckHandler.
eureka:
instance:
hostname: ${vcap.application.uris[0]}
- nonSecurePort: 80
+ nonSecurePort: 80
+ metadataMap:
+ instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
A vanilla Netflix Eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Spring Cloud Eureka provides a sensible default that looks like this: ${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}}. For example myhost:myappname:8080.
Using Spring Cloud you can override this by providing a unique identifier in eureka.instance.instanceId. For example:
By default a eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Using Spring Cloud you can override this by providing a unique identifier in eureka.instance.metadataMap.instanceId. For example:
eureka:
instance:
- instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
+ metadataMap:
+ instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
Once you have an app that is @EnableDiscoveryClient (or @EnableEurekaClient) you can use it to
+
Once you have an app that is @EnableEurekaClient you can use it to
discover service instances from the Eureka Server. One way to do that is to use the native
-com.netflix.discovery.EurekaClient (as opposed to the Spring
+com.netflix.discovery.DiscoveryClient (as opposed to the Spring
Cloud DiscoveryClient), e.g.
@Autowired
-private EurekaClient discoveryClient;
+private DiscoveryClient discoveryClient;
public String serviceUrl() {
InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false);
@@ -2830,7 +2224,7 @@ public String serviceUrl() {
-Don’t use the EurekaClient in @PostConstruct method or in a
+
Don’t use the DiscoveryClient in @PostConstruct method or in a
@Scheduled method (or anywhere where the ApplicationContext might
not be started yet). It is initialized in a SmartLifecycle (with
phase=0) so the earliest you can rely on it being available is in
@@ -2842,9 +2236,9 @@ another SmartLifecycle with higher phase.
-Alternatives to the native Netflix EurekaClient
+Alternatives to the native Netflix DiscoveryClient
-You don’t have to use the raw Netflix EurekaClient and usually it
+
You don’t have to use the raw Netflix DiscoveryClient and usually it
is more convenient to use it behind a wrapper of some sort. Spring
Cloud has support for Feign (a REST client
builder) and also Spring RestTemplate using
@@ -3147,6 +2541,9 @@ for details on the properties available.
The same thing applies if you are using @SessionScope or @RequestScope. You will know when you need to do this because of a runtime exception that says it can’t find the scoped context.
+
+In particular you might be interested
+
Health Indicator
@@ -3361,7 +2758,7 @@ explicitly in the @ComponentScan).
IPing ribbonPing: NoOpPing
-ServerList<Server> ribbonServerList: ConfigurationBasedServerList
+ServerList<Server> ribbonServerList: `ConfigurationBasedServerList
ServerListFilter<Server> ribbonServerListFilter: ZonePreferenceServerListFilter
@@ -3406,7 +2803,7 @@ server list will be constructed with "zone" information as provided in
the instance metadata (so on the client set
eureka.instance.metadataMap.zone), and if that is missing it can use
the domain name from the server hostname as a proxy for zone (if the
-flag approximateZoneFromHostname is set). Once the zone information is
+flag approximateZoneFromDomain is set). Once the zone information is
available it can be used in a ServerListFilter (by default it will
be used to locate a server in the same zone as the client because the
default is a ZonePreferenceServerListFilter).
@@ -3503,7 +2900,7 @@ public interface StoreClient {
List<Store> getStores();
@RequestMapping(method = RequestMethod.POST, value = "/stores/{storeId}", consumes = "application/json")
- Store update(@PathVariable("storeId") Long storeId, Store store);
+ Store update(@PathParameter("storeId") Long storeId, Store store);
}
@@ -3522,277 +2919,6 @@ don’t want to use Eureka, you can simply configure a list of servers
in your external configuration (see
above for example).
-
-Overriding Feign Defaults
-
-A central concept in Spring Cloud’s Feign support is that of the named client. Each feign client is part of an ensemble of components that work together to contact a remote server on demand, and the ensemble has a name that you give it as an application developer using the @FeignClient annotation. Spring Cloud creates a new ensemble as an
-ApplicationContext on demand for each named client using FeignClientsConfiguration. This contains (amongst other things) an feign.Decoder, a feign.Encoder, and a feign.Contract.
-
-
-Spring Cloud lets you take full control of the feign client by declaring additional configuration (on top of the FeignClientsConfiguration) using @FeignClient. Example:
-
-
-
-@FeignClient(name = "stores", configuration = FooConfiguration.class)
-public interface StoreClient {
- //..
-}
-
-
-
-In this case the client is composed from the components already in FeignClientsConfiguration together with any in FooConfiguration (where the latter will override the former).
-
-
-
-
-
-Warning
-
-
-The FooConfiguration has to be @Configuration but take care that it is not in a @ComponentScan for the main application context, otherwise it will be used for every @FeignClient. If you use @ComponentScan (or @SpringBootApplication) you need to take steps to avoid it being included (for instance put it in a separate, non-overlapping package, or specify the packages to scan explicitly in the @ComponentScan).
-
-
-
-
-
-
-
-
-Note
-
-
-The serviceId attribute is now deprecated in favor of the name attribute.
-
-
-
-
-
-
-
-
-Warning
-
-
-Previously, using the url attribute, did not require the name attribute. Using name is now required.
-
-
-
-
-
-Placeholders are supported in the name and url attributes.
-
-
-
-@FeignClient(name = "${feign.name}", url = "${feign.url}")
-public interface StoreClient {
- //..
-}
-
-
-
-Spring Cloud Netflix provides the following beans by default for feign (BeanType beanName: ClassName):
-
-
-
--
-
Decoder feignDecoder: ResponseEntityDecoder (which wraps a SpringDecoder)
-
--
-
Encoder feignEncoder: SpringEncoder
-
--
-
Logger feignLogger: Slf4jLogger
-
--
-
Contract feignContract: SpringMvcContract
-
--
-
Feign.Builder feignBuilder: HystrixFeign.Builder
-
-
-
-
-Spring Cloud Netflix does not provide the following beans by default for feign, but still looks up beans of these types from the application context to create the feign client:
-
-
-
--
-
Logger.Level
-
--
-
Retryer
-
--
-
ErrorDecoder
-
--
-
Request.Options
-
--
-
Collection<RequestInterceptor>
-
-
-
-
-Creating a bean of one of those type and placing it in a @FeignClient configuration (such as FooConfiguration above) allows you to override each one of the beans described. Example:
-
-
-
-@Configuration
-public class FooConfiguration {
- @Bean
- public Contract feignContractg() {
- return new feign.Contract.Default();
- }
-
- @Bean
- public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
- return new BasicAuthRequestInterceptor("user", "password");
- }
-}
-
-
-
-This replaces the SpringMvcContract with feign.Contract.Default and adds a RequestInterceptor to the collection of RequestInterceptor.
-
-
-Default configurations can be specified in the @EnableFeignClients attribute defaultConfiguration in a similar manner as described above. The difference is that this configuration will apply to all feign clients.
-
-
-
-Feign Hystrix Support
-
-If Hystrix is on the classpath, by default Feign will wrap all methods with a circuit breaker. Returning a com.netflix.hystrix.HystrixCommand is also available. This lets you use reactive patterns (with a call to .toObservable() or .observe() or asynchronous use (with a call to .queue()).
-
-
-To disable Hystrix support for Feign, set feign.hystrix.enabled=false.
-
-
-To disable Hystrix support on a per-client basis create a vanilla Feign.Builder with the "prototype" scope, e.g.:
-
-
-
-@Configuration
-public class FooConfiguration {
- @Bean
- @Scope("prototype")
- public Feign.Builder feignBuilder() {
- return Feign.builder();
- }
-}
-
-
-
-
-Feign Inheritance Support
-
-Feign supports boilerplate apis via single-inheritance interfaces.
-This allows grouping common operations into convenient base interfaces.
-Together with Spring MVC you can share the same contract for your
-REST endpoint and Feign client.
-
-
-UserService.java
-
-public interface UserService {
-
- @RequestMapping(method = RequestMethod.GET, value ="/users/{id}")
- User getUser(@PathVariable("id") long id);
-}
-
-
-
-UserResource.java
-
-@RestController
-public class UserResource implements UserService {
-
-}
-
-
-
-UserClient.java
-
-package project.user;
-
-@FeignClient("users")
-public interface UserClient extends UserService {
-
-}
-
-
-
-
-Feign request/response compression
-
-You may consider enabling the request or response GZIP compression for your
-Feign requests. You can do this by enabling one of the properties:
-
-
-
-feign.compression.request.enabled=true
-feign.compression.response.enabled=true
-
-
-
-Feign request compression gives you settings similar to what you may set for your web server:
-
-
-
-feign.compression.request.enabled=true
-feign.compression.request.mime-types=text/xml,application/xml,application/json
-feign.compression.request.min-request-size=2048
-
-
-
-These properties allow you to be selective about the compressed media types and minimum request threshold length.
-
-
-
-Feign logging
-
-A logger is created for each Feign client created. By default the name of the logger is the full class name of the interface used to create the Feign client. Feign logging only responds to the DEBUG level.
-
-
-application.yml
-
-logging.level.project.user.UserClient: DEBUG
-
-
-
-The Logger.Level object that you may configure per client, tells Feign how much to log. Choices are:
-
-
-
--
-
NONE, No logging (DEFAULT).
-
--
-
BASIC, Log only the request method and URL and the response status code and execution time.
-
--
-
HEADERS, Log the basic information along with request and response headers.
-
--
-
FULL, Log the headers, body, and metadata for both requests and responses.
-
-
-
-
-For example, the following would set the Logger.Level to FULL:
-
-
-
-@Configuration
-public class FooConfiguration {
- @Bean
- Logger.Level feignLoggerLevel() {
- return Logger.Level.FULL;
- }
-}
-
-
-
@@ -3816,7 +2942,7 @@ public class FooConfiguration {
-Archaius has its own set of configuration files and loading priorities. Spring applications should generally not use Archaius directly, but the need to configure the Netflix tools natively remains. Spring Cloud has a Spring Environment Bridge so Archaius can read properties from the Spring Environment. This allows Spring Boot projects to use the normal configuration toolchain, while allowing them to configure the Netflix tools, for the most part, as documented.
+Archaius has its own set of configuration files and loading priorities. Spring applications should generally not use Archaius directly., but the need to configure the Netflix tools natively remains. Spring Cloud has a Spring Environment Bridge so Archaius can read properties from the Spring Environment. This allows Spring Boot projects to use the normal configuration toolchain, while allowing them to configure the Netflix tools, for the most part, as documented.
@@ -3896,7 +3022,7 @@ configured routes map, then it will be unignored. Example:
application.yml
zuul:
- ignoredServices: '*'
+ ignoredServices: *
routes:
users: /myusers/**
@@ -3980,28 +3106,6 @@ users:
-You can provide convention between serviceId and routes using regexmapper.
-It uses regular expression named group to extract variables from serviceId and inject them
-into a route pattern.
-
-
-application.yml
-
- zuul:
- regexMapper:
- enabled: true
- servicePattern: "(?<name>^.+)-(?<version>v.+$)"
- routePattern: "${version}/${name}"
-
-
-
-This means that a serviceId "myusers-v1" will be mapped to route "/v1/myusers/".
-Any regular expression is accepted but all named group must be present in both servicePattern and routePattern.
-If servicePattern do not match a serviceId, the default behavior is used. In exemple above,
-a serviceId "myusers" will be mapped to route "/myusers/" (no version detected)
-These feature is disable by default and is only applied to discovered services.
-
-
To add a prefix to all mappings, set zuul.prefix to a value, such as
/api. The proxy prefix is stripped from the request before the
request is forwarded by default (switch this behaviour off with
@@ -4029,7 +3133,7 @@ Set that flag to "true" to have the Ribbon client automatically retry failed req
the Ribbon client configuration).
-The X-Forwarded-Host header is added to the forwarded requests by
+
The X-Forwarded-Host header added to the forwarded requests by
default. To turn it off set zuul.addProxyHeaders = false. The
prefix path is stripped by default, and the request to the backend
picks up a header "X-Forwarded-Prefix" ("/myusers" in the examples
@@ -4040,80 +3144,6 @@ above).
server if you set a default route ("/"), for example zuul.route.home:
/ would route all traffic (i.e. "/**") to the "home" service.
-
-If more fine-grained ignoring is needed, you can specify specific patterns to ignore.
-These patterns are being evaluated at the start of the route location process, which
-means prefixes should be included in the pattern to warrant a match. Ignored patterns
-span all services and supersede any other route specification.
-
-
-application.yml
-
- zuul:
- ignoredPatterns: /**/admin/**
- routes:
- users: /myusers/**
-
-
-
-This means that all calls such as "/myusers/101" will be forwarded to "/101" on the "users" service.
-But calls including "/admin/" will not resolve.
-
-
-
-Strangulation Patterns and Local Forwards
-
-A common pattern when migrating an existing application or API is to
-"strangle" old endpoints, slowly replacing them with different
-implementations. The Zuul proxy is a useful tool for this because you
-can use it to handle all traffic from clients of the old endpoints,
-but redirect some of the requests to new ones.
-
-
-Example configuration:
-
-
-application.yml
-
- zuul:
- routes:
- first:
- path: /first/**
- url: http://first.example.com
- second:
- path: /second/**
- url: forward:/second
- third:
- path: /third/**
- url: forward:/3rd
- legacy:
- path: /**
- url: http://legacy.example.com
-
-
-
-In this example we are strangling the "legacy" app which is mapped to
-all requests that do not match one of the other patterns. Paths in
-/first/ have been extracted into a new service with an external
-URL. And paths in /second/ are forwared so they can be handled
-locally, e.g. with a normal Spring @RequestMapping. Paths in
-/third/** are also forwarded, but with a different prefix
-(i.e. /third/foo is forwarded to /3rd/foo).
-
-
-
-
-
-Note
-
-
-The ignored pattterns aren’t completely ignored, they just
-aren’t handled by the proxy (so they are also effectively forwarded
-locally).
-
-
-
-
Uploading Files through Zuul
@@ -4296,325 +3326,6 @@ info:
-
-Metrics: Spectator, Servo, and Atlas
-
-
-When used together, Spectator/Servo and Atlas provide a near real-time operational insight platform.
-
-
-Spectator and Servo are Netflix’s metrics collection libraries. Atlas is a Netflix metrics backend to manage dimensional time series data.
-
-
-Servo served Netflix for several years and is still usable, but is gradually being phased out in favor of Spectator, which is only designed to work with Java 8. Spring Cloud Netflix provides support for both, but Java 8 based applications are encouraged to use Spectator.
-
-
-Dimensional vs. Hierarchical Metrics
-
-Spring Boot Actuator metrics are hierarchical and metrics are separated only by name. These names often follow a naming convention that embeds key/value attribute pairs (dimensions) into the name separated by periods. Consider the following metrics for two endpoints, root and star-star:
-
-
-
-{
- "counter.status.200.root": 20,
- "counter.status.400.root": 3,
- "counter.status.200.star-star": 5,
-}
-
-
-
-The first metric gives us a normalized count of successful requests against the root endpoint per unit of time. But what if the system had 20 endpoints and you want to get a count of successful requests against all the endpoints? Some hierarchical metrics backends would allow you to specify a wild card such as counter.status.200. that would read all 20 metrics and aggregate the results. Alternatively, you could provide a HandlerInterceptorAdapter that intercepts and records a metric like counter.status.200.all for all successful requests irrespective of the endpoint, but now you must write 20+1 different metrics. Similarly if you want to know the total number of successful requests for all endpoints in the service, you could specify a wild card such as counter.status.2.*.
-
-
-Even in the presence of wildcarding support on a hierarchical metrics backend, naming consistency can be difficult. Specifically the position of these tags in the name string can slip with time, breaking queries. For example, suppose we add an additional dimension to the hierarchical metrics above for HTTP method. Then counter.status.200.root becomes counter.status.200.method.get.root, etc. Our counter.status.200.* suddenly no longer has the same semantic meaning. Furthermore, if the new dimension is not applied uniformly across the codebase, certain queries may become impossible. This can quickly get out of hand.
-
-
-Netflix metrics are tagged (a.k.a. dimensional). Each metric has a name, but this single named metric can contain multiple statistics and 'tag' key/value pairs that allows more querying flexibility. In fact, the statistics themselves are recorded in a special tag.
-
-
-Recorded with Netflix Servo or Spectator, a timer for the root endpoint described above contains 4 statistics per status code, where the count statistic is identical to Spring Boot Actuator’s counter. In the event that we have encountered an HTTP 200 and 400 thus far, there will be 8 available data points:
-
-
-
-{
- "root(status=200,stastic=count)": 20,
- "root(status=200,stastic=max)": 0.7265630630000001,
- "root(status=200,stastic=totalOfSquares)": 0.04759702862580789,
- "root(status=200,stastic=totalTime)": 0.2093076914666667,
- "root(status=400,stastic=count)": 1,
- "root(status=400,stastic=max)": 0,
- "root(status=400,stastic=totalOfSquares)": 0,
- "root(status=400,stastic=totalTime)": 0,
-}
-
-
-
-
-Default Metrics Collection
-
-Without any additional dependencies or configuration, a Spring Cloud based service will autoconfigure a Servo MonitorRegistry and begin collecting metrics on every Spring MVC request. By default, a Servo timer with the name rest will be recorded for each MVC request which is tagged with:
-
-
-
--
-
HTTP method
-
--
-
HTTP status (e.g. 200, 400, 500)
-
--
-
URI (or "root" if the URI is empty), sanitized for Atlas
-
--
-
The exception class name, if the request handler threw an exception
-
--
-
The caller, if a request header with a key matching netflix.metrics.rest.callerHeader is set on the request. There is no default key for netflix.metrics.rest.callerHeader. You must add it to your application properties if you wish to collect caller information.
-
-
-
-
-Set the netflix.metrics.rest.metricName property to change the name of the metric from rest to a name you provide.
-
-
-If Spring AOP is enabled and org.aspectj:aspectjweaver is present on your runtime classpath, Spring Cloud will also collect metrics on every client call made with RestTemplate. A Servo timer with the name of restclient will be recorded for each MVC request which is tagged with:
-
-
-
--
-
HTTP method
-
--
-
HTTP status (e.g. 200, 400, 500), "CLIENT_ERROR" if the response returned null, or "IO_ERROR" if an IOException occurred during the execution of the RestTemplate method
-
--
-
URI, sanitized for Atlas
-
--
-
Client name
-
-
-
-
-
-Metrics Collection: Spectator
-
-To enable Spectator metrics, include a dependency on spring-boot-starter-spectator:
-
-
-
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-spectator</artifactId>
- </dependency>
-
-
-
-In Spectator parlance, a meter is a named, typed, and tagged configuration and a metric represents the value of a given meter at a point in time. Spectator meters are created and controlled by a registry, which currently has several different implementations. Spectator provides 4 meter types: counter, timer, gauge, and distribution summary.
-
-
-Spring Cloud Spectator integration configures an injectable com.netflix.spectator.api.Registry instance for you. Specifically, it configures a ServoRegistry instance in order to unify the collection of REST metrics and the exporting of metrics to the Atlas backend under a single Servo API. Practically, this means that your code may use a mixture of Servo monitors and Spectator meters and both will be scooped up by Spring Boot Actuator MetricReader instances and both will be shipped to the Atlas backend.
-
-
-Spectator Counter
-
-A counter is used to measure the rate at which some event is occurring.
-
-
-
-// create a counter with a name and a set of tags
-Counter counter = registry.counter("counterName", "tagKey1", "tagValue1", ...);
-counter.increment(); // increment when an event occurs
-counter.increment(10); // increment by a discrete amount
-
-
-
-The counter records a single time-normalized statistic.
-
-
-
-Spectator Timer
-
-A timer is used to measure how long some event is taking. Spring Cloud automatically records timers for Spring MVC requests and conditionally RestTemplate requests, which can later be used to create dashboards for request related metrics like latency:
-
-
-Request Latency
-image::RequestLatency.png []
-
-
-
-// create a timer with a name and a set of tags
-Timer timer = registry.timer("timerName", "tagKey1", "tagValue1", ...);
-
-// execute an operation and time it at the same time
-T result = timer.record(() -> fooReturnsT());
-
-// alternatively, if you must manually record the time
-Long start = System.nanoTime();
-T result = fooReturnsT();
-timer.record(System.nanoTime() - start, TimeUnit.NANOSECONDS);
-
-
-
-The timer simultaneously records 4 statistics: count, max, totalOfSquares, and totalTime. The count statistic will always match the single normalized value provided by a counter if you had called increment() once on the counter for each time you recorded a timing, so it is rarely necessary to count and time separately for a single operation.
-
-
-For long running operations, Spectator provides a special LongTaskTimer.
-
-
-
-Spectator Gauge
-
-Gauges are used to determine some current value like the size of a queue or number of threads in a running state. Since gauges are sampled, they provide no information about how these values fluctuate between samples.
-
-
-The normal use of a gauge involves registering the gauge once in initialization with an id, a reference to the object to be sampled, and a function to get or compute a numeric value based on the object. The reference to the object is passed in separately and the Spectator registry will keep a weak reference to the object. If the object is garbage collected, then Spectator will automatically drop the registration. See the note in Spectator’s documentation about potential memory leaks if this API is misused.
-
-
-
-// the registry will automatically sample this gauge periodically
-registry.gauge("gaugeName", pool, Pool::numberOfRunningThreads);
-
-// manually sample a value in code at periodic intervals -- last resort!
-registry.gauge("gaugeName", Arrays.asList("tagKey1", "tagValue1", ...), 1000);
-
-
-
-
-Spectator Distribution Summaries
-
-A distribution summary is used to track the distribution of events. It is similar to a timer, but more general in that the size does not have to be a period of time. For example, a distribution summary could be used to measure the payload sizes of requests hitting a server.
-
-
-
-// the registry will automatically sample this gauge periodically
-DistributionSummary ds = registry.distributionSummary("dsName", "tagKey1", "tagValue1", ...);
-ds.record(request.sizeInBytes());
-
-
-
-
-
-Metrics Collection: Servo
-
-
-
-
-Warning
-
-
-If your code is compiled on Java 8, please use Spectator instead of Servo as Spectator is destined to replace Servo entirely in the long term.
-
-
-
-
-
-In Servo parlance, a monitor is a named, typed, and tagged configuration and a metric represents the value of a given monitor at a point in time. Servo monitors are logically equivalent to Spectator meters. Servo monitors are created and controlled by a MonitorRegistry. In spite of the above warning, Servo does have a wider array of monitor options than Spectator has meters.
-
-
-Spring Cloud integration configures an injectable com.netflix.servo.MonitorRegistry instance for you. Once you have created the appropriate Monitor type in Servo, the process of recording data is wholly similar to Spectator.
-
-
-Creating Servo Monitors
-
-If you are using the Servo MonitorRegistry instance provided by Spring Cloud (specifically, an instance of DefaultMonitorRegistry), Servo provides convenience classes for retrieving counters and timers. These convenience classes ensure that only one Monitor is registered for each unique combination of name and tags.
-
-
-To manually create a Monitor type in Servo, especially for the more exotic monitor types for which convenience methods are not provided, instantiate the appropriate type by providing a MonitorConfig instance:
-
-
-
-MonitorConfig config = MonitorConfig.builder("timerName").withTag("tagKey1", "tagValue1").build();
-
-// somewhere we should cache this Monitor by MonitorConfig
-Timer timer = new BasicTimer(config);
-monitorRegistry.register(timer);
-
-
-
-
-
-Metrics Backend: Atlas
-
-Atlas was developed by Netflix to manage dimensional time series data for near real-time operational insight. Atlas features in-memory data storage, allowing it to gather and report very large numbers of metrics, very quickly.
-
-
-Atlas captures operational intelligence. Whereas business intelligence is data gathered for analyzing trends over time, operational intelligence provides a picture of what is currently happening within a system.
-
-
-Spring Cloud provides a spring-cloud-starter-atlas that has all the dependencies you need. Then just annotate your Spring Boot application with @EnableAtlas and provide a location for your running Atlas server with the netflix.atlas.uri property.
-
-
-Global tags
-
-Spring Cloud enables you to add tags to every metric sent to the Atlas backend. Global tags can be used to separate metrics by application name, environment, region, etc.
-
-
-Each bean implementing AtlasTagProvider will contribute to the global tag list:
-
-
-
-@Bean
-AtlasTagProvider atlasCommonTags(
- @Value("${spring.application.name}") String appName) {
- return () -> Collections.singletonMap("app", appName);
-}
-
-
-
-
-Using Atlas
-
-To bootstrap a in-memory standalone Atlas instance:
-
-
-
-$ curl -LO https://github.com/Netflix/atlas/releases/download/v1.4.2/atlas-1.4.2-standalone.jar
-$ java -jar atlas-1.4.2-standalone.jar
-
-
-
-
-
-
-Tip
-
-
-An Atlas standalone node running on an r3.2xlarge (61GB RAM) can handle roughly 2 million metrics per minute for a given 6 hour window.
-
-
-
-
-
-Once running and you have collected a handful of metrics, verify that your setup is correct by listing tags on the Atlas server:
-
-
-
-$ curl http://ATLAS/api/v1/tags
-
-
-
-
-
-
-Tip
-
-
-After executing several requests against your service, you can gather some very basic information on the request latency of every request by pasting the following url in your browser: http://ATLAS/api/v1/graph?q=name,rest,:eq,:avg
-
-
-
-
-
-The Atlas wiki contains a compilation of sample queries for various scenarios.
-
-
-Make sure to check out the alerting philosophy and docs on using double exponential smoothing to generate dynamic alert thresholds.
-
-
-
-
-
Spring Cloud Bus
@@ -4673,98 +3384,21 @@ After executing several requests against your service, you can gather some very
-Customizing the Message Broker
+Customizing the AMQP ConnectionFactory
-Spring Cloud Bus uses
-Spring Cloud Stream to
-broadcast the messages so to get messages to flow you only need to
-include the binder implementation of your choice in the
-classpath. There are convenient starters specifically for the bus with
-AMQP, Kafka and Redis
-(spring-cloud-starter-bus-[amqp,kafka,redis]). Generally speaking
-Spring Cloud Stream relies on Spring Boot autoconfiguration
-conventions for configuring middleware, so for instance the AMQP
-broker address can be changed with spring.rabbitmq.*
-configuration properties. Spring Cloud Bus has a handful of native
-configuration properties in spring.cloud.bus.*
-(e.g. spring.cloud.bus.destination is the name of the topic to use
-the the externall middleware). Normally the defaults will suffice.
+If you are using AMQP there needs to be a ConnectionFactory (from
+Spring Rabbit) in the application context. If there is a single
+ConnectionFactory it will be used, or if there is a one qualified as
+@BusConnectionFactory it will be preferred over others, otherwise
+the @Primary one will be used. If there are multiple unqualified
+connection factories there will be an error.
-To lean more about how to customize the message broker settings
-consult the Spring Cloud Stream documentation.
-
-
-
-
-Tracing Bus Events
-
-
-Bus events (subclasses of RemoteApplicationEvent) can be traced by
-setting spring.cloud.bus.trace.enabled=true. If you do this then the
-Spring Boot TraceRepository (if it is present) will show each event
-sent and all the acks from each service instance. Example (from the
-/trace endpoint):
-
-
-
-{
- "timestamp": "2015-11-26T10:24:44.411+0000",
- "info": {
- "signal": "spring.cloud.bus.ack",
- "type": "RefreshRemoteApplicationEvent",
- "id": "c4d374b7-58ea-4928-a312-31984def293b",
- "origin": "stores:8081",
- "destination": "*:**"
- }
- },
- {
- "timestamp": "2015-11-26T10:24:41.864+0000",
- "info": {
- "signal": "spring.cloud.bus.sent",
- "type": "RefreshRemoteApplicationEvent",
- "id": "c4d374b7-58ea-4928-a312-31984def293b",
- "origin": "customers:9000",
- "destination": "*:**"
- }
- },
- {
- "timestamp": "2015-11-26T10:24:41.862+0000",
- "info": {
- "signal": "spring.cloud.bus.ack",
- "type": "RefreshRemoteApplicationEvent",
- "id": "c4d374b7-58ea-4928-a312-31984def293b",
- "origin": "customers:9000",
- "destination": "*:**"
- }
-}
-
-
-
-This trace shows that a RefreshRemoteApplicationEvent was sent from
-customers:9000, broadcast to all services, and it was received
-(acked) by customers:9000 and stores:8081.
-
-
-To handle the ack signals yourself you could add an @EventListener
-for the AckRemoteAppplicationEvent and SentApplicationEvent types
-to your app (and enable tracing). Or you could tap into the
-TraceRepository and mine the data from there.
-
-
-
-
-
-Note
-
-
-Any Bus application can trace acks, but sometimes it will be
-useful to do this in a central service that can do more complex
-queries on the data. Or forward it to a specialized tracing service.
-
-
-
+Note that Spring Boot (as of 1.2.2) creates a ConnectionFactory that
+is not @Primary, so if you want to use one connection factory for
+the bus and another for business messages, you need to create both,
+and annotate them @BusConnectionFactory and @Primary respectively.
@@ -4802,8 +3436,8 @@ Spring CLI v1.2.3.RELEASE
-$ gvm install springboot 1.3.0.M5
-$ gvm use springboot 1.3.0.M5
+$ gvm install springboot 1.2.3.RELEASE
+$ gvm use springboot 1.2.3.RELEASE
@@ -4812,7 +3446,7 @@ $ gvm use springboot 1.3.0.M5
$ mvn install
-$ spring install org.springframework.cloud:spring-cloud-cli:1.1.0.BUILD-SNAPSHOT
+$ spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE
@@ -4912,7 +3546,7 @@ AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...