Skip to main content

Lightweight RabbitMQ manager built on top of pika

Project description

Rabbit Manager

Rabbit Manager is a simple, Python-based utility for managing RabbitMQ message queues. It provides an easy-to-use interface for sending, receiving, and processing messages from RabbitMQ queues, with built-in support for automatic reconnections and error handling.

Key Features:

  • Send messages to RabbitMQ queues.
  • Receive messages from queues with automatic acknowledgement.
  • Automatically reconnect on connection loss.
  • Easily handle multiple messages and batch operations.
  • Supports queue size inspection.
  • Iterable interface for message consumption.

This tool is ideal for developers looking to integrate RabbitMQ into their Python applications with minimal overhead.

Requirements

  • Python >= 3.10
  • Pika (installed via project dependencies)

Install from PyPI (package name: rabbit-manager):

uv add rabbit-manager

or

pip install rabbit-manager

Install for local development with uv (recommended):

uv sync --dev

Alternatively, using pip for editable dev install:

pip install -e ".[dev]"

Quick Start (RabbitManager)

from rabbit_manager import RabbitManager

# Create a manager for a RabbitMQ queue
manager = RabbitManager(
    "my_queue",              # queue_name (positional argument, required)
    username="guest",        # keyword-only (required)
    password="guest",        # keyword-only (required)
    host="localhost",        # optional, defaults to "localhost"
    port=5672,               # optional, defaults to 5672
    queue_durable=True,      # optional, defaults to True
    message_ttl_minutes=10,  # optional, defaults to 0
    confirm_delivery=True,   # optional, defaults to True
)

# Use as a context manager to auto-open/close connection
with manager as q:
    # Add a message
    delivered = q.add("hello world")
    print("Delivered:", delivered)

    # Check queue size
    print("Queue size:", q.size())

    # Get one message (non-blocking)
    msg = q.get()
    print("Got:", msg)

    # Block and wait for a message (with optional timeout)
    msg2 = q.consume(timeout=5)
    print("Consumed:", msg2)

# Manual open/close usage
manager.open()
manager.add("another message")
print("Size:", manager.size())
print("Get:", manager.get())
manager.close()

Notes:

  • The example assumes a local RabbitMQ instance on localhost:5672 with guest/guest credentials.
  • When confirm_delivery=True, publishing raises on delivery issues (e.g., unroutable or NACK).
  • message_ttl_minutes>0 sets per-queue message TTL.

Testing

Before running tests, activate the virtual environment:

source .venv/bin/activate

Run the test suite:

pytest test.py -v

See more options in TEST_README.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbit_manager-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rabbit_manager-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file rabbit_manager-0.1.2.tar.gz.

File metadata

  • Download URL: rabbit_manager-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for rabbit_manager-0.1.2.tar.gz
Algorithm Hash digest
SHA256 51fec9654eed7ad70ab3d3e645a0b11d023ba4a49f282d8c4473a283e17f0328
MD5 a76e82e3af1cf2cfdc04d3e37ab54275
BLAKE2b-256 a5f6177954f8bed0a97bfd060f08de91f67c3947e9f8583b5e665e779486fb04

See more details on using hashes here.

File details

Details for the file rabbit_manager-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: rabbit_manager-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for rabbit_manager-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a35ee565a8b1747b86cfcce2dca70f3d4f20da3a7cca1fe3f11ccd3c5e1fea9
MD5 db79b5a973f29e991f1ea2209e4773d2
BLAKE2b-256 d792045902a119ed120f1bf15f48492f2cca12a24b893e805f6c3254556a02f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page