Keploy logo
RabbitMQ logo

Keploy as a RabbitMQ testing framework

Keploy tests RabbitMQ publishers and consumers by recording the AMQP protocol beneath your client, capturing publish confirms, deliveries, and acknowledgements, then replaying them during tests. No broker runs in CI and no queue or exchange has to be declared.

Generate RabbitMQ tests free
keploy record -c "./orders-service"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a RabbitMQ team

Captured at the AMQP 0-9-1 protocol

Keploy reads the protocol beneath your client, recording publishes with the broker's confirm, deliveries with their routing keys and headers, and the acks or nacks your consumer sent back.

  • Below amqplib, pika, Bunny, and the Java client
  • Publisher confirms captured
  • Routing keys and headers preserved
  • Ack and nack ordering kept
The problem

Why RabbitMQ integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing RabbitMQ: by hand, with Testcontainers RabbitMQ, or with Keploy

A real broker gives true routing semantics and makes every consumer test wait on asynchronous delivery. Keploy records the exchanges once and replays them deterministically.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for RabbitMQ vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
fake_publisher.py
hand-written
# Hand-written fake: nothing is serialised or routed.
class FakePublisher:
def __init__(self):
self.published = []
 
def publish(self, exchange, routing_key, payload):
# No exchange type, no binding, no confirm.
self.published.append((routing_key, payload))
 
def test_publishes_a_confirmed_order():
publisher = FakePublisher()
OrderService(publisher).confirm("ord_1")
 
assert len(publisher.published) == 1

This asserts a method was called. A wrong routing key or an unbound exchange would pass here and silently drop the message in production.

Testcontainers RabbitMQ1–2 hours
test_orders_amqp.py
tool-assisted
# Testcontainers RabbitMQ: a real broker per suite.
import json, pika, pytest
from testcontainers.rabbitmq import RabbitMqContainer
 
@pytest.fixture(scope="session")
def broker():
with RabbitMqContainer("rabbitmq:3-management") as rmq:
declare_topology(rmq.get_connection_params())
yield rmq
 
def test_publishes_a_confirmed_order(broker):
service = build_service(broker.get_connection_params())
service.confirm("ord_1")
 
# Poll until it arrives, or give up. This is the flaky part.
method, _, body = consume_one(broker, "orders.confirmed", timeout=10)
 
assert method is not None
assert json.loads(body)["id"] == "ord_1"

Real routing and confirms, at the cost of a broker per suite and a ten-second poll window that turns CI load into test failures.

With Keploy~5 minutes
mocks.yaml
auto-generated
# Recorded with: keploy record -c './orders-service'
# The AMQP exchange, captured at the wire protocol.
version: api.keploy.io/v1beta1
kind: AMQP
name: mock-4
spec:
publish:
exchange: orders
routing_key: orders.confirmed
properties:
content_type: "application/json"
delivery_mode: 2
# The bytes your serialiser actually produced.
body_base64: "eyJpZCI6Im9yZF8xIiwic3RhdGUiOiJDT05GSVJNRUQifQ=="
# The broker's real confirm.
response:
confirmed: true
delivery_tag: 918
deliver:
queue: orders.confirmed.q
redelivered: false

The routing key, message properties, and the broker's confirm are all recorded, so a topology or serialiser mistake surfaces as a diff with no polling.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

RabbitMQ testing tools, compared

The options a team on message brokers actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your RabbitMQ app once, replay it forever

Keploy sits below your RabbitMQ process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a RabbitMQ service and captures the dependency calls it makes.

RabbitMQ logo
Your RabbitMQ app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+3 more RabbitMQ clients
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Quick start

Your first RabbitMQ test suite in under five minutes

Every command below runs against your existing RabbitMQ service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "./orders-service"
  3. 3Exercise the paths you care about

    Trigger the endpoint that publishes, then let your consumer process the message so both halves of the exchange are recorded.

    curl -X POST localhost:8080/orders/ord_1/confirm -d '{"paymentToken":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "./orders-service" --delay 10

Ready to try it on your own RabbitMQ service?

Ecosystem

Works with the rest of your RabbitMQ stack

Keploy records at the network layer, so framework and driver choices inside your RabbitMQ app do not change how it captures traffic.

FAQ

RabbitMQ testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.