Codacy Badge Build Status Coverage Status Maven Central JitPack License FOSSA Status

Mock for RabbitMQ Java amqp-client.

Compatible with versions 4.0.0 to 5.7.3 of com.rabbitmq:amqp-client

Compatible with versions 3.6.3 to 4.0.0 with the com.github.fridujo.rabbitmq.mock.compatibility package.


This project aims to emulate RabbitMQ behavior for test purposes, through:

Example Use

Replace the use of com.rabbitmq.client.ConnectionFactory by MockConnectionFactory

ConnectionFactory factory = new MockConnectionFactory();
try (Connection conn = factory.newConnection()) {
    try (Channel channel = conn.createChannel()) {
        GetResponse response = channel.basicGet(queueName, autoAck);
        byte[] body = response.getBody();
        long deliveryTag = response.getEnvelope().getDeliveryTag();

        // Do what you need with the body

        channel.basicAck(deliveryTag, false);

More details in integration-test

With Spring

Change underlying RabbitMQ ConnectionFactory by MockConnectionFactory

class TestConfiguration {
    ConnectionFactory connectionFactory() {
        return new CachingConnectionFactory(new MockConnectionFactory());

More details in integration-test


Any contribution is greatly appreciated. Please check out the guide for more details.

Open in Gitpod

Getting Started


Add the following dependency to your pom.xml



Add the following dependency to your build.gradle

repositories {

// ...

dependencies {
    // ...
    // ...

Building from Source

You need JDK-8 to build RabbitMQ-Mock. The project can be built with Maven using the following command.

mvn clean package

Tests are split in:

Installing in the Local Maven Repository

The project can be installed in a local Maven Repository for usage in other projects via the following command.

mvn clean install

Using the latest SNAPSHOT

The master of the project pushes SNAPSHOTs in Sonatype's repo.

To use the latest master build add Sonatype OSS snapshot repository, for Maven:


For Gradle:

repositories {
    // ...
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"


FOSSA Status