如何监控 amqp/rabbitMQ 与 Spring 的连接?

How to monitor amqp/rabbitMQ connection with Spring?

我们有两个不同的 AMQP 服务器 (RabbitMQ) 并为每个服务器配置了一个活页夹。

检查每个 amqp 服务器的连接状态的最佳方法是什么?

一种方法似乎是使用 AmqpTemplateCachingConnectionFactory,其中可以配置主机。但是有没有更简单的方法呢?

我也试过List<HealthIndicator>。但是它只包含一个 RabbitHealthIndicator 而应该有两个

我们的配置:

spring:
  cloud:
    stream:
      binders:
        binder1:
          type: rabbit
          environment:
            spring:
              rabbitmq:
                host: localhost
                port: 5672
                password: guest
                username: guest
        binder2:
          type: rabbit
          environment:
            spring:
              rabbitmq:
                host: localhost
                port: 56721
                password: guest
                username: guest

因此,您必须在第二个 ConnectionFactory 上为 RabbitTemplate 再声明一个 RabbitHealthIndicator

http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#_writing_custom_healthindicators