Hop is a Java client for the RabbitMQ HTTP API.
Hop is designed to be easy to use from other JVM languages, primarily Groovy, Scala, and Kotlin.
N.B. that Clojure already includes an HTTP API client as part of Langohr, and you should use Langohr instead.
This project is relatively young and not 100% feature complete but the key API operations are covered. The docs largely don't exist. The API may change but radical changes are unlikely.
This section will be updated as the project matures.
Project artifacts are available from Maven Central and repo.spring.io.
If you use Maven, add the following repository
definition to your pom.xml
:
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/release</url>
</repository>
The most recent release is
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>http-client</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
Add the following to your build.gradle
:
repositories {
maven {
url "https://repo.spring.io/release"
}
}
Current (unpublished) snapshot release is
compile "com.rabbitmq:http-client:1.1.0.RELEASE"
Hop faithfully follows RabbitMQ HTTP API conventions in its API. You interact with the server
using a single class, Client
, which needs an API endpoint and
a pair of credentials to be instantiated:
import com.rabbitmq.http.Client;
Client c = new Client("http://127.0.0.1:15672/api/", "guest", "guest");
c.getOverview();
// list cluster nodes
c.getNodes();
// get status and metrics of individual node
c.getNode("[email protected]");
// list client connections
c.getConnections();
// get status and metrics of individual connection
c.getConnection("127.0.0.1:61779 -> 127.0.0.1:5672");
// forcefully close connection
c.closeConnection("127.0.0.1:61779 -> 127.0.0.1:5672");
// list all channels
c.getChannels();
// list channels on individual connection
c.getChannels("127.0.0.1:61779 -> 127.0.0.1:5672");
// list detailed channel info
c.getChannel("127.0.0.1:61779 -> 127.0.0.1:5672 (3)");
// get status and metrics of individual vhost
c.getVhost("/");
TBD
TBD
TBD
// list all queues
c.getQueues();
// list all queues in a vhost
c.getQueues();
// declare a queue that's not durable, auto-delete,
// and non-exclusive
c.declareQueue("/", "queue1", new QueueInfo(false, true, false));
// bind a queue
c.bindQueue("/", "queue1", "amq.fanout", "routing-key");
// delete a queue
c.deleteQueue("/", "queue1");
// list bindings where exchange "an.exchange" is source
// (other things are bound to it)
c.getBindingsBySource("/", "an.exchange");
// list bindings where exchange "an.exchange" is destination
// (it is bound to other exchanges)
c.getBindingsByDestination("/", "an.exchange");
gradle check
The test suite assumes RabbitMQ is running locally with stock settings and rabbitmq-management plugin enabled.
Michael Klishin, 2014-2016. Pivotal Software Inc., 2014-current.