Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-eggers committed Feb 14, 2016
1 parent 5390930 commit 36d33cf
Show file tree
Hide file tree
Showing 12 changed files with 783 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target/
/.settings/
/.classpath
/.project
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: java
jdk:
- oraclejdk8
install: mvn install -Dgpg.skip=true
after_success:
- mvn clean test cobertura:cobertura coveralls:report
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
spring-rabbitmq-actuator
============

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.itelg.spring/spring-rabbitmq-actuator/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.itelg.spring/spring-rabbitmq-actuator)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/ab6ef73712914dabac91965fe49eb297)](https://www.codacy.com/app/eggers-julian/spring-rabbitmq-actuator)
[![Coverage Status](https://coveralls.io/repos/julian-eggers/spring-rabbitmq-actuator/badge.svg?branch=master&service=github)](https://coveralls.io/github/julian-eggers/spring-rabbitmq-actuator?branch=master)
[![Build Status](https://travis-ci.org/julian-eggers/spring-rabbitmq-actuator.svg?branch=master)](https://travis-ci.org/julian-eggers/spring-rabbitmq-actuator)

SpringBoot RabbitMQ Actuator

#### Maven
```xml
<dependencies>
<dependency>
<groupId>com.itelg.spring</groupId>
<artifactId>spring-rabbitmq-actuator</artifactId>
<version>0.2.5-RELEASE</version>
</dependency>
</dependencies>
```

#### Example
```java
@Bean
public HealthIndicator rabbitQueueCheckHealthIndicator()
{
RabbitQueueCheckHealthIndicator healthIndicator = new RabbitQueueCheckHealthIndicator();
healthIndicator.addQueueCheck(exampleQueue1, 10000, 1);
healthIndicator.addQueueCheck(exampleQueue2, 50000, 3);
return healthIndicator;
}
```

#### Response ([health.json](http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-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
}
}
}
```
196 changes: 196 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.itelg.spring</groupId>
<artifactId>spring-rabbitmq-actuator</artifactId>
<name>spring-rabbitmq-actuator</name>
<description>SpringBoot RabbitMQ actuator</description>
<url>https://github.com/julian-eggers/spring-rabbitmq-actuator</url>
<version>0.2.5-RELEASE</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<cobertura.version>2.7</cobertura.version>
<coveralls.version>4.1.0</coveralls.version>
<powermock.version>1.6.3</powermock.version>
<easymock.version>3.4</easymock.version>
</properties>

<scm>
<url>https://github.com/julian-eggers/spring-rabbitmq-actuator</url>
<connection>scm:git:https://github.com/julian-eggers/spring-rabbitmq-actuator.git</connection>
<developerConnection>scm:git:https://github.com/julian-eggers/spring-rabbitmq-actuator.git</developerConnection>
</scm>

<developers>
<developer>
<name>Julian Eggers</name>
<email>eggers.julian@gmail.com</email>
</developer>
</developers>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>

<build>
<plugins>
<!-- BUILD AND FILES -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- TEST AND COVERAGE -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.version}</version>
<configuration>
<format>xml</format>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls.version}</version>
</plugin>
<!-- DEPLOYMENT -->
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>de.jutzig</groupId>
<artifactId>github-release-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>github-upload</id>
<phase>deploy</phase>
<goals>
<goal>release</goal>
</goals>
<configuration>
<releaseName>${project.version}</releaseName>
<tag>${project.version}</tag>
<artifact>${project.build.directory}/${project.artifactId}-${project.version}.jar</artifact>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>1.2.8.RELEASE</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.5.3.RELEASE</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
<optional>true</optional>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${easymock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
49 changes: 49 additions & 0 deletions src/main/java/com/itelg/spring/actuator/rabbitmq/QueueCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.itelg.spring.actuator.rabbitmq;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.util.Assert;

public class QueueCheck
{
private Queue queue;
private RabbitAdmin rabbitAdmin;
private int maxMessageCount;
private int minConsumerCount;

public QueueCheck(Queue queue, int maxMessageCount, int minConsumerCount)
{
this.queue = queue;
this.maxMessageCount = maxMessageCount;
this.minConsumerCount = minConsumerCount;
validateRabbitAdmin(queue);
}

private void validateRabbitAdmin(Queue queue)
{
Assert.notEmpty(queue.getDeclaringAdmins(), "At least one RabbitAdmin must be declared");
Object object = queue.getDeclaringAdmins().iterator().next();
Assert.isInstanceOf(RabbitAdmin.class, object, "DeclaringAdmin must be a RabbitAdmin");
this.rabbitAdmin = (RabbitAdmin) object;
}

public Queue getQueue()
{
return queue;
}

public RabbitAdmin getRabbitAdmin()
{
return rabbitAdmin;
}

public int getMaxMessageCount()
{
return maxMessageCount;
}

public int getMinConsumerCount()
{
return minConsumerCount;
}
}
Loading

0 comments on commit 36d33cf

Please sign in to comment.