java springcloud version b2b2c social e-commerce spring cloud distributed microservices (13) circuit breaker aggregation monitoring (Hystrix Turbine)

java springcloud version b2b2c social e-commerce spring cloud distributed microservices (13) circuit breaker aggregation monitoring (Hystrix Turbine)

Spring cloud b2b2c e-commerce social platform source code, please add penguin request: one zero three eight seven seven four six two six. Describes how to use Hystrix Dashboard to monitor the Hystrix command of the circuit breaker. When we have many services, it is necessary to aggregate the data of Hystrix Dashboard for all services. This requires another component of Spring Cloud, Hystrix Turbine.

1. Introduction
to Hystrix Turbine Looking at the data of a single Hystrix Dashboard does not have much value. If you want to see the Hystrix Dashboard data of this system, you need to use Hystrix Turbine. Hystrix Turbine integrates Hystrix Dashboard data for each service. The use of Hystrix Turbine is very simple, you only need to introduce the corresponding dependencies and add annotations and configurations.

2. Preparatory work
The project used in this article is the project of the previous article, which is to be modified on this basis. Because we need multiple service dashboards, we need to build another service, named service-lucy. Its basic configuration is the same as service-hi, so I won t explain it in detail here.

3. create service-turbine to
introduce the corresponding dependencies:

<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-turbine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-turbine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
 

Add the annotation @EnableTurbine to its entry class ServiceTurbineApplication to turn on the turbine. The @EnableTurbine annotation includes the @EnableDiscoveryClient annotation, that is, the registration service is turned on.

@SpringBootApplication
@EnableTurbine
public class ServiceTurbineApplication {
 
    public static void main(String[] args) {
 
            new SpringApplicationBuilder(ServiceTurbineApplication.class).web(true).run(args);
    }
}
 

Configuration file application.yml:

spring:
  application.name: service-turbine
server:
  port: 8769
security.basic.enabled: false
turbine:
  aggregator:
    clusterConfig: default   #  "," default http://.../turbine.stream?cluster={clusterConfig } 
  appConfig: service-hi,service-lucy  ###  Eureka serviceId 
  clusterNameExpression: new String("default")
  # 1. clusterNameExpression appName turbine.aggregator.clusterConfig 
  # 2.  clusterNameExpression: default turbine.aggregator.clusterConfig default
  # 3.  clusterNameExpression: metadata['cluster'] eureka.instance.metadata-map.cluster: ABC turbine.aggregator.clusterConfig: ABC
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
 

4. Turbine demo
starts the eureka-server, service-hi, service-lucy, and service-turbine projects in sequence.

Open the browser and enter: http://localhost:8769/turbine.stream, the interface is as follows:

Insert picture description here

Request in turn:

http://localhost:8762/hi?name=forezp
 
http://localhost:8763/hi?name=forezp
 

The source code of the B2B2C e-commerce platform that needs JAVASpring Cloud large-scale enterprise distributed microservice cloud construction, please add penguin.