Python with RabbitMQ—simplified so you won't have to.
Project description
Development Status
Note: Currently under active development.
Features
- Use out-of-the-box and thread-safe
Consumer
andPublisher
classes created frompika
for your projects and tests. - Built-in retry-backoff logic for connecting, consuming, and publishing.
- Works with Python 3.
Getting Started
Installation
PyRMQ is available at PyPi.
pip install pyrmq
Usage
Publishing
Just instantiate the feature you want with their respective settings. PyRMQ already works out of the box with RabbitMQ's default initialization settings.
from pyrmq import Publisher
publisher = Publisher(
exchange_name="exchange_name",
queue_name="queue_name",
routing_key="routing_key",
)
publisher.publish({"pyrmq": "My first message"})
Consuming
Intantiating a Consumer
automatically starts it in its own thread making it
non-blocking by default. When run after the code from before, you should be
able to receive the published data.
from pyrmq import Consumer
def callback(data):
print(f"Received {data}!")
Consumer(
exchange_name="exchange_name",
queue_name="queue_name",
routing_key="routing_key",
callback=callback
)
Documentation
Complete document is found at https://pyrmq.readthedocs.io
run build and generate coverage report.
Testing
For development, just run:
pytest
To test for all the supported Python versions:
pip install tox
tox
To test for a specific Python version:
tox -e py38
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.