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
max_priority=10, # optional, defaults to 0
)
# 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)
# Add a message with priority (requires max_priority > 0)
delivered_priority = q.add("priority message", priority=5)
print("Delivered with priority:", delivered_priority)
# 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:5672withguest/guestcredentials. - When
confirm_delivery=True, publishing raises on delivery issues (e.g., unroutable or NACK). message_ttl_minutes>0sets per-queue message TTL.- Message priority works only when
max_priority>0, and can be set per message viaadd(..., priority=...).
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.
Metadata
Release files for rabbit-manager 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rabbit_manager-0.2.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rabbit_manager-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / rabbit_manager-0.2.0.tar.gz
| Download URL | rabbit_manager-0.2.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b1e1c2b6738479e2a3761398453e826f9ef3a3204828161558f963ad3a67557
|
|
BLAKE2b-256 checksum How to use checksums |
e11a05487bd21520f1373271bf333182153dde438a93eeff04b097bb5e2dbc10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / rabbit_manager-0.2.0-py3-none-any.whl
| Download URL | rabbit_manager-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b79b32d15f2d2412940bccf14f57dad5fedb548d85cac5ec802ee33fec58c5ee
|
|
BLAKE2b-256 checksum How to use checksums |
a3bc6f888df89004df95f6ba7243f64acf6f1a250b75bfaac218a122f469f5ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|