hystrix配合turbine使用消息队列收集信息
0
使用的是Spring Cloud 2.0。
使用turbine
聚合hystrix
监控信息,默认使用turbine
通过hystrix.stream
获取hystrix
的信息,依赖:
<!-- turbine -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<!-- hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
如果使用stream
来聚合,需要加入stream
和stream
的binder
(spring-cloud-stream-binder-rabbit
):
<!-- turbine -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine-stream</artifactId>
</dependency>
<!-- hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-stream</artifactId>
</dependency>
properties配置:
#默认配置
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.addresses=${spring.rabbitmq.host}:${spring.rabbitmq.port}
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.rabbitmq.virtual-host=/
#stream绑定
spring.cloud.stream.binders.rabbit.type=rabbit
spring.cloud.stream.binders.rabbit.environment.spring.rabbitmq.host=${spring.rabbitmq.host}
spring.cloud.stream.binders.rabbit.environment.spring.rabbitmq.port=${spring.rabbitmq.port}
spring.cloud.stream.binders.rabbit.environment.spring.rabbitmq.username=${spring.rabbitmq.username}
spring.cloud.stream.binders.rabbit.environment.spring.rabbitmq.password=${spring.rabbitmq.password}
spring.cloud.stream.binders.rabbit.environment.spring.rabbitmq.virtual-host=${spring.rabbitmq.virtual-host}
spring.cloud.stream.default-binder=rabbit
#采集
#hystrix流
hystrix.stream.queue.destination=${system.message.turbine}
#关闭hystrix.stream端点
management.endpoint.hystrix.stream.enabled=false
#turbine端
#turbine配置
turbine.stream.destination=${system.message.turbine}
项目参考:https://gitee.com/acgist/api
如果静态资源加载不出来参考:https://www.acgist.com/article/559.html
更新了新版本的Spring Cloud配置变化:
#hystrix队列
hystrix.stream.queue.destination=${system.message.turbine}
spring.cloud.stream.bindings.hystrixStreamOutput.destination=${system.message.turbine}
#====================turbine====================
turbine.stream.destination=${system.message.turbine}
spring.cloud.stream.bindings.turbineStreamInput.destination=${system.message.turbine}