A Django app to publish and consume rmq-messages via Pika.
Project description
Django-pika-pubsub is a simple Django app to publish and consume rmq-messages via Pika.
Using default rmq exchange.
Quick start
Add “django_pika_pubsub” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'django_pika_pubsub', ]
Add the following to your settings.py module:
PUBSUB = { 'RABBITMQ_USERNAME': os.getenv('RABBITMQ_USERNAME'), 'RABBITMQ_PASSWORD': os.getenv('RABBITMQ_PASSWORD'), 'RABBITMQ_HOST': os.getenv('RABBITMQ_HOST'), 'RABBITMQ_PORT': int(os.getenv('RABBITMQ_PORT')), }
Do something similar for producing messages:
from django_pika_pubsub import Producer ... producer = Producer.get_producer() producer.produce( body={'id': order.id}, routing_key='order.sent.order_id.1.0.0' )
Do something similar for consuming messages:
consumer = MyConsumer.get_consumer() consumer.consume( routing_key='test', callback=callback, ) def callback(channel, method, properties, body): payload = json.loads(body) order_id = payload.get('id') if order_id: print(f'{order_id=}')
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
File details
Details for the file django-pika-pubsub-0.6.tar.gz
.
File metadata
- Download URL: django-pika-pubsub-0.6.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03f0415ac983f1f219cdb15831770334429e0bc9dde45b32704c7ab5ada646c9 |
|
MD5 | 8369197aa5b2c32c65817e8fb671c83b |
|
BLAKE2b-256 | 58963e3620078602b666f0fbb681b058f144d0d8aa6a94d9ebaa22f280e90be1 |