Skip to main content

Lightweight RabbitMQ client helpers (blocking/pika) with Sender and Listener utilities.

Project description

rabbitmq-pika-adapter

Lightweight RabbitMQ client helpers built on pika (sync) and aio-pika (async).

Core API:

  • Sync publish: PublisherPool (recommended)
  • Sync consume: Listener
  • Async publish/consume: AsyncSender, AsyncListener (optional extra)
  • Facade: RabbitMQClient (recommended entrypoint)

Acknowledgements (auto_ack)

Consumers support two acknowledgement modes:

  • auto_ack=False (default): at-least-once delivery. The library will ack after your callback returns successfully, and nack/requeue on exception. Your handler should be idempotent because messages may be redelivered.
  • auto_ack=True (legacy): at-most-once delivery. Messages are considered acknowledged on delivery. If your callback raises or the process crashes mid-processing, RabbitMQ will not redeliver that message.

Recommendation: for most "work queue" style consumers, use auto_ack=False.

See docs/USAGE.md for details and examples.

Installation

From PyPI:

pip install rabbitmq-pika-adapter

Async support:

pip install rabbitmq-pika-adapter[async]

This enables AsyncSender and AsyncListener.

Usage

Recommended entrypoint:

  • RabbitMQClient(...).publisher(...) / .listener(...)

Direct usage (advanced/explicit):

  • Listener(message_type, callback, ...) - thread-based consumer.
  • PublisherPool(message_type, ...) - sync publisher with pooled channels.
  • AsyncListener(message_type, callback, ...) - asyncio-based consumer.
  • AsyncSender(message_type, ...) - asyncio-based publisher.

See examples/usage.py and docs/USAGE.md.

Examples

  • High-throughput sync publish+consume demo (prints stats for both):

    python examples/usage.py throughput

Notes:

  • The repo uses a src/ layout. If you want to run examples without installing the package, examples/usage.py will automatically add src/ to sys.path.

Testing

Install test deps:

pip install -e .[test]

Run unit tests:

python -m pytest -q

Integration tests (no Docker)

Integration tests are opt-in and require a reachable RabbitMQ. Set env vars:

  • RABBITMQ_HOST (or RABBITMQ_SERVER)
  • RABBITMQ_PORT
  • RABBITMQ_VHOST
  • RABBITMQ_USER
  • RABBITMQ_PASSWORD

Then run:

python -m pytest -m integration -q

Publishing to PyPI

This repo publishes from GitHub Actions:

  • Pushes to develop publish to TestPyPI.
  • Pushes to release publish to PyPI.

Manual build/publish:

python -m pip install build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*

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

rabbitmq_pika_adapter-0.2.0.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

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

rabbitmq_pika_adapter-0.2.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file rabbitmq_pika_adapter-0.2.0.tar.gz.

File metadata

  • Download URL: rabbitmq_pika_adapter-0.2.0.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for rabbitmq_pika_adapter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bfba682881449c7c3064cfe7ccc88a2214fc1f3303a505f4ae5aa3f91695cfaf
MD5 b1b8ad851857ebf340197580b18f82bf
BLAKE2b-256 6c2253a629b39f1b86a956bd0c49ebd620b7acb900e5abe7e08f8b83715658cc

See more details on using hashes here.

File details

Details for the file rabbitmq_pika_adapter-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rabbitmq_pika_adapter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03172949774ee2882e9a54258e36f9d6f0b0232b60942ddd7905a481a4d8d0f3
MD5 891a575cc7339d2bc3670c5d8459fe25
BLAKE2b-256 0c1254dccd0a27a4c7d93e0976463a2c27b6cc5101d1745410fd0ba53c6bf426

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