-
@Configuration
-@EnableAutoConfiguration
-@EnableHystrix
+@SpringBootApplication
+@EnableCircuitBreaker
public class Application {
public static void main(String[] args) {
@@ -2205,10 +2405,10 @@ for details on the properties available.
Turbine
-
Looking at an individual instances Hystrix data is not very useful in terms of the overall health of the system. Turbine is an application that aggregates all of the relevant /hystrix.stream endpoints into a combined /turbine.stream for use in the Hystrix Dashboard. Individual instances are located via Eureka. Running Turbine is as simple as annotating your main class with the @EnableTurbine annotation. All of the documented configuration properties from the Turbine 1 wiki apply. The only difference is that the turbine.instanceUrlSuffix does not need the port prepended as this is handled automatically unless turbine.instanceInsertPort=false.
+
Looking at an individual instances Hystrix data is not very useful in terms of the overall health of the system. Turbine is an application that aggregates all of the relevant /hystrix.stream endpoints into a combined /turbine.stream for use in the Hystrix Dashboard. Individual instances are located via Eureka. Running Turbine is as simple as annotating your main class with the @EnableTurbine annotation (e.g. using spring-cloud-starter-turbine to set up the classpath). All of the documented configuration properties from the Turbine 1 wiki apply. The only difference is that the turbine.instanceUrlSuffix does not need the port prepended as this is handled automatically unless turbine.instanceInsertPort=false.
-
Configuration key turbine.appConfig is a list of eureka serviceId’s that turbine will use to lookup instances. The turbine stream is then used in the Hystrix dashboard using a url that looks like: http://my.turbine.sever:8080/turbine.stream?cluster=<CLUSTERNAME> (the cluster parameter can be omitted if the name is "default"). The cluster parameter must match an entry in turbine.aggregator.clusterConfig. Value returned from eureka are uppercase, thus we expect this example to work if there is an app registered with Eureka called "customers":
+
The configuration key turbine.appConfig is a list of eureka serviceIds that turbine will use to lookup instances. The turbine stream is then used in the Hystrix dashboard using a url that looks like: http://my.turbine.sever:8080/turbine.stream?cluster=<CLUSTERNAME> (the cluster parameter can be omitted if the name is "default"). The cluster parameter must match an entry in turbine.aggregator.clusterConfig. Values returned from eureka are uppercase, thus we expect this example to work if there is an app registered with Eureka called "customers":
@@ -2219,7 +2419,22 @@ for details on the properties available.
-
The clusterName can be customized by a SPEL expression in turbine.clusterNameExpression. For example, turbine.clusterNameExpression=aSGName would get the cluster name from the AWS ASG name. To use the "default" cluster for all apps you need a string literal expression (with single quotes):
+
The clusterName can be customized by a SPEL expression in turbine.clusterNameExpression with root an instance of InstanceInfo. The default value is appName, which means that the Eureka serviceId ends up as the cluster key (i.e. the InstanceInfo for customers has an appName of "CUSTOMERS"). A different example would be turbine.clusterNameExpression=aSGName, which would get the cluster name from the AWS ASG name. Another example:
+
+
+
+
turbine:
+ aggregator:
+ clusterConfig: SYSTEM,USER
+ appConfig: customers,stores,ui,admin
+ clusterNameExpression: metadata.cluster
+
+
+
+
In this case, the cluster name from 4 services is pulled from their metadata map, and is expected to have values that include "SYSTEM" and "USER".
+
+
+
To use the "default" cluster for all apps you need a string literal expression (with single quotes):
@@ -2315,6 +2530,24 @@ public class TestConfiguration {
RibbonClientConfiguration together with any in FooConfiguration
(where the latter generally 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 shared by all the @RibbonClients. 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).
+ |
+
+
+
Spring Cloud Netflix provides the following beans by default for ribbon
(BeanType beanName: ClassName):
@@ -2422,33 +2655,6 @@ configuration like this
-
-
Spring RestTemplate as a Ribbon Client
-
-
You can use Ribbon indirectly via an autoconfigured RestTemplate
-(provided Spring Cloud and Ribbon are both on the classpath):
-
-
-
-
public class MyClass {
- @Autowired
- private RestTemplate restTemplate;
-
- public String doOtherStuff() {
- String results = restTemplate.getForObject("http://stores/stores", String.class);
- return results;
- }
-}
-
-
-
-
The URI is inspected to see if it has a full host name, or a virtual
-one. If it is virtual the Ribbon client is used to create a full
-physical address. See
-RibbonAutoConfiguration
-for details of how the RestTemplate is set up.
-
-