• Stars
    star
    137
  • Rank 266,071 (Top 6 %)
  • Language
    Java
  • Created about 10 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RabbitMQ HTTP API client for Java, Groovy, and other JVM languages

Hop, Java Client for the RabbitMQ HTTP API

Build Status

Hop is a Java client for the RabbitMQ HTTP API.

Polyglot

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.

Reactive

As of Hop 2.1.0, a new reactive, non-blocking IO client based on Reactor Netty is available. Note the original blocking IO client remains available.

Project Maturity

This project is mature and covers all key RabbitMQ HTTP API endpoints.

Meaningful breaking API changes are reflected in the version. User documentation is currently kept in this README.

Pre-requisites

As of 4.0, Hop requires Java 11 or later.

Maven Artifacts

Maven Central

Project artifacts are available from Maven Central.

For milestones and release candidates, declare the milestone repository in your dependency manager.

Dependency Manager Configuration

If you want to use the blocking IO client, add the following dependencies:

pom.xml
<dependency>
  <groupId>com.rabbitmq</groupId>
  <artifactId>http-client</artifactId>
  <version>5.0.0</version>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.15.2</version>
</dependency>
build.gradle
compile "com.rabbitmq:http-client:5.0.0"
compile "com.fasterxml.jackson.core:jackson-databind:2.15.2"

If you want to use the reactive, non-blocking IO client, add the following dependencies:

pom.xml
<dependency>
  <groupId>com.rabbitmq</groupId>
  <artifactId>http-client</artifactId>
  <version>5.0.0</version>
</dependency>
<dependency>
  <groupId>io.projectreactor.netty</groupId>
  <artifactId>reactor-netty</artifactId>
  <version>1.1.0</version>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.15.2</version>
</dependency>
build.gradle
compile "com.rabbitmq:http-client:5.0.0"
compile "io.projectreactor.netty:reactor-netty:1.1.0"
compile "com.fasterxml.jackson.core:jackson-databind:2.15.2"

Milestones and Release Candidates

Milestones and release candidates are available on the RabbitMQ Milestone Repository:

Maven:

pom.xml
<repositories>
  <repository>
    <id>packagecloud-rabbitmq-maven-milestones</id>
    <url>https://packagecloud.io/rabbitmq/maven-milestones/maven2</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>

Gradle:

build.gradle
repositories {
  maven {
    url "https://packagecloud.io/rabbitmq/maven-milestones/maven2"
  }
}

Snapshots

To use snapshots, add the following dependencies:

pom.xml
<dependency>
  <groupId>com.rabbitmq</groupId>
  <artifactId>http-client</artifactId>
  <version>5.1.0-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.15.2</version>
</dependency>
build.gradle
compile "com.rabbitmq:http-client:5.1.0-SNAPSHOT"
compile "com.fasterxml.jackson.core:jackson-databind:2.15.2"

Add the Sonatype OSS snapshot repository to your dependency manager:

Maven:

pom.xml
<repositories>
  <repository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
    <releases>
      <enabled>false</enabled>
    </releases>
  </repository>
</repositories>

Gradle:

build.gradle
repositories {
  maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
  mavenCentral()
}

Usage Guide

Instantiating a Client

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;
import com.rabbitmq.http.client.ClientParameters;

Client c = new Client(
  new ClientParameters()
    .url("http://127.0.0.1:15672/api/")
    .username("guest")
    .password("guest")
);

HTTP Layer (Synchronous Client)

The synchronous client uses Java 11โ€™s HttpClient internally.

Advanced Configuration

The client uses sensible defaults, but it is possible to customize the HttpClient instance and requests creation with JdkHttpClientHttpLayer#configure():

HttpLayerFactory httpLayerFactory =
  JdkHttpClientHttpLayer.configure()  // (1)
    .clientBuilderConsumer(
      clientBuilder ->  // (2)
        clientBuilder
          .connectTimeout(Duration.ofSeconds(10)))
    .requestBuilderConsumer(
      requestBuilder ->  // (3)
        requestBuilder
          .timeout(Duration.ofSeconds(10))
          .setHeader("Authorization", authorization("guest", "guest")))
    .create();  // (4)

Client c =
    new Client(
        new ClientParameters()
            .url("http://127.0.0.1:15672/api/")
            .username("guest")
            .password("guest")
            .httpLayerFactory(httpLayerFactory));  // (5)
  1. Configure the HTTP layer factory

  2. Configure the creation of the HttpClient instance

  3. Configure the creation of each request

  4. Instantiate the HTTP layer factory

  5. Set the HTTP layer factory

TLS

Set the SSLContext on the HttpClient builder to configure TLS:

SSLContext sslContext = SSLContext.getInstance("TLSv1.3");  // (1)
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), random);  // (2)
HttpLayerFactory factory =
  JdkHttpClientHttpLayer.configure()
    .clientBuilderConsumer(builder -> builder.sslContext(sslContext))  // (3)
    .create();
  1. Create the SSL context

  2. Initialize the SSL context

  3. Set the SSL context on the client builder

Note the HttpClient enables hostname verification by default. This is a good thing for security, but it can generate surprising failures.

Hostname verification can be disabled globally with the jdk.internal.httpclient.disableHostnameVerification system property for development or test purposes, but at no cost in a production environment.

Getting Overview

c.getOverview();

Node and Cluster Status

// list cluster nodes
c.getNodes();

// get status and metrics of individual node
c.getNode("[email protected]");

Operations on Connections

// 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");

Operations on Channels

// 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)");

Operations on Vhosts

// get status and metrics of individual vhost
c.getVhost("/");

Managing Users

TBD

Managing Permissions

TBD

Operations on Exchanges

TBD

Operations on Queues

// 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");

Operations on Bindings

// 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");

Running Tests (with Docker)

Start the broker:

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management

Configure the broker for the test suite:

export HOP_RABBITMQCTL="DOCKER:rabbitmq"
./bin/before_build.sh

Launch the test suite:

./mvnw test

Running Tests

To run the suite against a specific RabbitMQ node, export HOP_RABBITMQCTL and HOP_RABBITMQ_PLUGINS to point at rabbitmqctl and rabbitmq-plugins from the installation.

Then set up the node that is assumed to be running:

./bin/before_build.sh

This will enable several plugins used by the test suite and configure the node to use a much shorter event refresh interval so that HTTP API reflects system state changes with less of a delay.

To run the tests:

./mvnw test

The test suite assumes RabbitMQ is running locally with stock settings and a few plugins are enabled:

  • rabbitmq_management (listening on port 15672)

  • rabbitmq_shovel_management

  • rabbitmq_federation_management

To run the suite against a specific RabbitMQ node, export HOP_RABBITMQCTL and HOP_RABBITMQ_PLUGINS to point at rabbitmqctl and rabbitmq-plugins from the installation.

The test suite can use a different port than 15672 by specifying it with the rabbitmq.management.port system property:

./mvnw test -Drabbitmq.management.port=15673

Versioning

This library uses semantic versioning.

Support

See the RabbitMQ Java libraries support page for the support timeline of this library.

License

Michael Klishin, 2014-2016.

VMware, Inc. or its affiliates, 2014-2022.

More Repositories

1

rabbitmq-server

Open source RabbitMQ: core server and tier 1 (built-in) plugins
Starlark
11,952
star
2

rabbitmq-tutorials

Tutorials for using RabbitMQ in various ways
Java
6,393
star
3

rabbitmq-dotnet-client

RabbitMQ .NET client for .NET Standard 2.0+ and .NET 4.6.2+
C#
2,056
star
4

rabbitmq-delayed-message-exchange

Delayed Messaging for RabbitMQ
Erlang
1,992
star
5

internals

High level architecture overview
1,444
star
6

amqp091-go

An AMQP 0-9-1 Go client maintained by the RabbitMQ team. Originally by @streadway: `streadway/amqp`
Go
1,319
star
7

rabbitmq-java-client

RabbitMQ Java client
Java
1,227
star
8

cluster-operator

RabbitMQ Cluster Kubernetes Operator
Go
865
star
9

ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Erlang
800
star
10

rabbitmq-website

RabbitMQ website
JavaScript
769
star
11

erlang-rpm

Latest Erlang/OTP releases packaged as a zero dependency RPM, just enough for running RabbitMQ
Shell
540
star
12

rabbitmq-management

RabbitMQ Management UI and HTTP API
Erlang
369
star
13

tls-gen

Generates self-signed x509/TLS/SSL certificates useful for development
Python
362
star
14

rabbitmq-perf-test

A load testing tool
Java
355
star
15

khepri

Khepri is a tree-like replicated on-disk database library for Erlang and Elixir.
Erlang
317
star
16

erlando

Erlando
Erlang
306
star
17

rabbitmq-sharding

Sharded logical queues for RabbitMQ: a queue type which provides improved parallelism and thoughput at the cost of total ordering
Erlang
303
star
18

rabbitmq-peer-discovery-k8s

Kubernetes-based peer discovery mechanism for RabbitMQ
Erlang
296
star
19

rabbitmq-objc-client

RabbitMQ client for Objective-C and Swift
Objective-C
241
star
20

chef-cookbook

Development repository for Chef cookbook RabbitMQ
Ruby
211
star
21

rmq-0mq

ZeroMQ support in RabbitMQ
Erlang
210
star
22

rabbitmq-consistent-hash-exchange

RabbitMQ Consistent Hash Exchange Type
Erlang
209
star
23

rabbitmq-auth-backend-http

HTTP-based authorisation and authentication for RabbitMQ
Makefile
199
star
24

rabbitmq-erlang-client

Erlang client for RabbitMQ
Erlang
185
star
25

rabbitmq-mqtt

RabbitMQ MQTT plugin
Erlang
173
star
26

rabbitmq-stream-go-client

A client library for RabbitMQ streams
Go
167
star
27

rabbitmq-stream-rust-client

A client library for RabbitMQ streams
Rust
148
star
28

rabbitmq-prometheus

A minimalistic Prometheus exporter of core RabbitMQ metrics
Erlang
145
star
29

looking_glass

An Erlang/Elixir/BEAM profiler tool
Erlang
139
star
30

messaging-topology-operator

RabbitMQ messaging topology operator
Go
123
star
31

rabbitmq-cli

Command line tools for RabbitMQ
Elixir
105
star
32

rabbitmq-stream-dotnet-client

RabbitMQ client for the stream protocol
C#
100
star
33

rabbitmq-web-stomp-examples

Makefile
94
star
34

rabbitmq-amqp1.0

AMQP 1.0 support for RabbitMQ
Erlang
93
star
35

rabbitmq-web-stomp

Provides support for STOMP over WebSockets
Erlang
89
star
36

rabbitmq-recent-history-exchange

RabbitMQ Recent History Exchange
Makefile
82
star
37

diy-kubernetes-examples

Examples that demonstrate how deploy a RabbitMQ cluster to Kubernetes, the DIY way
Makefile
82
star
38

rabbitmq-event-exchange

Expose broker events as messages
Erlang
78
star
39

rabbitmq-clusterer

This project is ABANDONWARE. Use https://www.rabbitmq.com/cluster-formation.html instead.
Erlang
72
star
40

rabbitmq-message-timestamp

A RabbitMQ plugin that adds a timestamp to all incoming messages
Makefile
72
star
41

rabbitmq-common

Common library used by rabbitmq-server and rabbitmq-erlang-client
Erlang
66
star
42

rabbitmq-c

The official rabbitmq-c sources have moved to:
C
65
star
43

tgir

Official repository for Thank Goodness It's RabbitMQ (TGIR)!
Makefile
65
star
44

rabbitmq-jms-client

RabbitMQ JMS client
Java
61
star
45

rabbit-socks

Websocket and Socket.IO support for RabbitMQ (deprecated -- see https://github.com/sockjs/sockjs-erlang instead)
Erlang
58
star
46

rabbitmq-web-mqtt

Provides support for MQTT over WebSockets
Erlang
55
star
47

rabbitmq-stream-java-client

RabbitMQ Stream Java Client
Java
55
star
48

rabbitmq-top

Adds top-like information on the Erlang VM to the management plugin.
Makefile
55
star
49

rabbitmq-shovel

RabbitMQ Shovel plugin
Erlang
53
star
50

rabbitmq-auth-mechanism-ssl

RabbitMQ TLS (x509 certificate) authentication mechanism
Makefile
52
star
51

aten

An adaptive accrual node failure detection library for Elixir and Erlang
Erlang
50
star
52

rabbitmq-stomp

RabbitMQ STOMP plugin
Erlang
49
star
53

rabbitmq-tracing

RabbitMQ Tracing
Erlang
48
star
54

mnevis

Raft-based, consensus oriented implementation of Mnesia transactions
Erlang
48
star
55

gen-batch-server

A generic batching server for Erlang and Elixir
Erlang
47
star
56

rabbitmq-priority-queue

Priority Queues
46
star
57

osiris

Log based streaming subsystem for RabbitMQ
Erlang
45
star
58

rabbitmq-management-visualiser

RabbitMQ Topology Visualiser
JavaScript
41
star
59

rabbitmq-oauth2-tutorial

Explore integration of RabbitMQ with Oauth 2.0 auth backend plugin
Shell
41
star
60

rabbitmq-peer-discovery-consul

Consul-based peer discovery backend for RabbitMQ 3.7.0+
Erlang
40
star
61

rabbitmq-federation

RabbitMQ Federation plugin
Erlang
39
star
62

rabbitmq-auth-backend-oauth2

RabbitMQ authorization backend that uses OAuth 2.0 (JWT) tokens
Erlang
38
star
63

rabbitmq-codegen

RabbitMQ protocol code-generation and machine-readable spec
Python
37
star
64

support-tools

A staging area for various support and troubleshooting tools that are not (or not yet) included into RabbitMQ distribution
Shell
36
star
65

ra-kv-store

Raft-based key-value store
Clojure
33
star
66

rabbitmq-perf-html

Web page to view performance results
JavaScript
33
star
67

rabbitmq-web-mqtt-examples

Examples for the Web MQTT plugin
JavaScript
32
star
68

rabbitmq-public-umbrella

Work with ease on multiple RabbitMQ sub-projects, e.g. core broker, plugins and some client libraries
Makefile
32
star
69

rules_erlang

Bazel rules for building Erlang applications and libraries
Starlark
32
star
70

rabbitmq-smtp

RabbitMQ SMTP gateway
Erlang
31
star
71

rabbitmq-metronome

RabbitMQ example plugin
Makefile
27
star
72

rabbitmq-rtopic-exchange

RabbitMQ Reverse Topic Exchange
Erlang
27
star
73

horus

Erlang library to create standalone modules from anonymous functions
Erlang
25
star
74

workloads

Continuous validation of RabbitMQ workloads
JavaScript
24
star
75

rabbitmq-tracer

AMQP 0-9-1 protocol analyzer
Java
24
star
76

rabbitmq-peer-discovery-aws

AWS-based peer discovery backend for RabbitMQ 3.7.0+
Erlang
24
star
77

rabbitmq-shovel-management

RabbitMQ Shovel Management
Makefile
23
star
78

rabbitmq-auth-backend-ldap

RabbitMQ LDAP authentication
Erlang
22
star
79

rabbitmq-management-themes

Makefile
22
star
80

rabbitmq-auth-backend-amqp

Authentication over AMQP RPC
Erlang
20
star
81

rabbitmq-amqp1.0-client

Erlang AMQP 1.0 client
Erlang
20
star
82

erlang-data-structures

Erlang Data Structures
Erlang
20
star
83

chocolatey-package

RabbitMQ chocolatey package
PowerShell
19
star
84

lz4-erlang

LZ4 compression library for Erlang.
C
19
star
85

rabbitmq-service-nodejs-sample

A simple node.js sample app for the RabbitMQ service/add-on
JavaScript
18
star
86

rabbitmq-auth-backend-oauth2-spike

See rabbitmq/rabbitmq-auth-backend-oauth2 instead.
Erlang
17
star
87

rabbitmq-msg-store-index-eleveldb

LevelDB-based message store index for RabbitMQ
Erlang
17
star
88

rabbitmq-management-agent

RabbitMQ Management Agent
Erlang
17
star
89

rabbitmq-auth-backend-cache

Authorisation result caching plugin (backend) for RabbitMQ
Erlang
17
star
90

rabbitmq-jsonrpc-channel

RabbitMQ JSON-RPC Channels
JavaScript
15
star
91

rabbitmq-ha

Highly available queues for RabbitMQ
Erlang
15
star
92

rabbitmq-jsonrpc

RabbitMQ JSON-RPC Integration
Makefile
15
star
93

stdout_formatter

Erlang library to format paragraphs, lists and tables as plain text
Erlang
15
star
94

rabbitmq-peer-discovery-etcd

etcd-based peer discovery backend for RabbitMQ 3.7.0+
Erlang
15
star
95

rabbitmq-federation-management

RabbitMQ Federation Management
Makefile
14
star
96

credentials-obfuscation

Tiny library/OTP app for credential obfuscation
Erlang
14
star
97

rabbitmq-server-release

RabbitMQ packaging and release engineering bits that do not belong to the Concourse pipelines.
Shell
13
star
98

seshat

Erlang
13
star
99

rabbitmq-jms-topic-exchange

Custom exchange that implements JMS topic selection for RabbitMQ
Erlang
13
star
100

rabbitmq-store-exporter

RabbitMQ Store Exporter
Erlang
12
star