SpringBoot RabbitMQ Actuator (Queue Metrics & Health-Checks)
<dependency>
<groupId>com.itelg.spring</groupId>
<artifactId>spring-rabbitmq-actuator</artifactId>
<version>0.5.0-RELEASE</version>
</dependency>
Precondition (Example)
You have to add the declaring RabbitAdmin to each queue. The specific RabbitAdmin is required to fetch the queue-information.
@Bean
public Queue exampleQueue()
{
Queue queue = new Queue("com.itelg.spring.rabbitmq.test");
queue.setAdminsThatShouldDeclare(rabbitAdmin());
return queue;
}
@Bean
public HealthIndicator rabbitQueueCheckHealthIndicator()
{
RabbitQueueCheckHealthIndicator healthIndicator = new RabbitQueueCheckHealthIndicator();
healthIndicator.addQueueCheck(exampleQueue1, 10000, 1);
healthIndicator.addQueueCheck(exampleQueue2, 50000, 3);
return healthIndicator;
}
Response (health.json)
{
"status" : "DOWN",
"rabbitQueueCheck" :
{
"status" : "DOWN",
"com.examle.exampleQueue1" :
{
"status" : "UP",
"currentMessageCount" : 214,
"maxMessageCount" : 10000,
"currentConsumerCount" : 5,
"minConsumerCount" : 1
},
"com.example.exampleQueue2" :
{
"status" : "DOWN",
"currentMessageCount" : 67377,
"maxMessageCount" : 50000,
"currentConsumerCount" : 0,
"minConsumerCount" : 3
}
}
}
@EnableRabbitMetrics
@Configuration
public class RabbitMetricsConfiguration
{
}
Response (metrics.json)
{
"mem" : 626258,
"mem.free" : 460251,
"processors" : 16,
"instance.uptime" : 17148451,
...
"rabbit.queue.com_examle_exampleQueue1.currentMessageCount" : 214,
"rabbit.queue.com_examle_exampleQueue1.currentConsumerCount" : 5,
"rabbit.queue.com_examle_exampleQueue2.currentMessageCount" : 67377,
"rabbit.queue.com_examle_exampleQueue2.currentConsumerCount" : 0,
...
}