In order to solve this problem, we can send the monitoring messages of turbine services to RabbitMQ. Monitoring messages are then fetched from RabbitMQ in Turbine, decoupling the class service from Turbine.

Let’s use a case to demonstrate how to achieve this effect

1. Start the RabbitMQ service

Obviously we need to install and start a RabbitMQ service

Create a Consumer service

Create a Consumer service and send dashboard monitoring information to the RabbitMQ service.

1. Create projects

2. Add dependencies

The core dependencies are as follows. For complete dependencies, refer to git complete code

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> < artifactId > spring - the cloud - starter - hystrix < / artifactId > < version > 1.3.2. RELEASE < / version > < / dependency > < the dependency > <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-hystrix-stream</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-rabbit</artifactId> </dependency>Copy the code

3. Modify the configuration

Add the RabbitMQ configuration information

Name =shop-product-consumer-hystrix-dashboard server.port=9090 Point to another registry eureka.client.serviceUrl.defaultZone=http://dpb:123456@eureka1:8761/eureka/,http://dpb:123456@eureka2:8761/eureka/ #Feign Hystrix is disabled by default. The default value is: False feign. Hystrix. Enabled = true spring. The rabbitmq. Host = 192.168.88.150 spring. The rabbitmq. Port = 5672 spring.rabbitmq.username=dpb spring.rabbitmq.password=123 spring.rabbitmq.virtualHost=/Copy the code

4. Modify the startup class

Start the service and access the tests

@EnableFeignClients @EnableDiscoveryClient @SpringBootApplication @EnableHystrix @EnableHystrixDashboard public class SpringcloudFeignProdcutConsumerApplication { public static void main(String[] args) { SpringApplication.run(SpringcloudFeignProdcutConsumerApplication.class, args); }}Copy the code

Access request: http://localhost:9090/list

For monitoring data: http://localhost:9090/hystrix.stream

Also note the RabbitMQ console

You can see that there is a change

3. Create Turbine services

1. Create projects

2. Add dependencies

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId>  </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine-stream</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-stream-rabbit</artifactId> </dependency> </dependencies>Copy the code

3. Modify the configuration

= = = = = = = = = = = = Point to another registry eureka.client.serviceUrl.defaultZone=http://dpb:123456@eureka1:8761/eureka/,http://dpb:123456@eureka2:8761/eureka/ Spring. The rabbitmq. Host = 192.168.88.150 spring. The rabbitmq. Port = 5672 spring. The rabbitmq. Username = DPB spring. The rabbitmq. Password = 123 spring.rabbitmq.virtualHost=/Copy the code

4. Start the class

Pay attention to the annotation

@SpringBootApplication
@EnableTurbineStream
public class SpringcloudFeignProdcutConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringcloudFeignProdcutConsumerApplication.class, args);
    }

}

Copy the code

Start the service

Note The monitoring data is obtained from RabbitMQ

Create dashboard visual services

The visualized service can use the previously created one

Can be

See the consumer monitoring data, the case is successful!