Enhance RabbitMQ services for a Python Django application
Project description
django_rabbitmq_utils
To enhance the RabbitMQ library features in Python Django, to utilize additional libraries and features that complement RabbitMQ's functionality.
requirements
For running this, you need to have python3
installed on your system.
Installation
pip install django-rabbitmq-utils==0.0.1
Example
from django_rabbitmq_utils.rabbitmq import send_message_with_retry, consume_messages_from_queue
def send_notification(message):
send_message_with_retry(message)
def start_message_consumer():
consume_messages_from_queue('my_queue')
# settings.py
CELERY_QUEUES = getattr(settings, 'CELERY_QUEUES', ())
CELERY_QUEUES += message_routing.routing.get_queues()
# celery.py
from kombu import Connection
from django_rabbitmq_utils.routing import get_exchange
app = Celery('your_project')
@app.task(bind=True)
def process_message(self, body):
# Connect to RabbitMQ and publish the message with routing key
with Connection(app.broker_connection()) as connection:
exchange = get_exchange()
producer = connection.Producer(serializer='json')
producer.publish(body, exchange=exchange, routing_key='key1')
# settings.py
import ssl
from django_rabbitmq_utils.rabbitmq_ssl import RABBITMQ_SSL_CONFIG
BROKER_URL = 'amqp://<username>:<password>@<rabbitmq_host>:<rabbitmq_port>/<vhost>'
BROKER_USE_SSL = True
BROKER_SSL_OPTIONS = RABBITMQ_SSL_CONFIG
# seetings.py
COMMANDS = {
**rabbitmq_integration.register_commands()
}
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.
Source Distribution
Built Distribution
Close
Hashes for django-rabbitmq-utils-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9edf5d34a80973fc2f39974a13b7f86770aac5b698a2d2f138c609d6d3c39bee |
|
MD5 | c3a8b6a00421fbd72709016468f193bb |
|
BLAKE2b-256 | 7f9233add929953619ff709a7bad3076bff20ee3961bc1cbad4646ca0c64a7fb |
Close
Hashes for django_rabbitmq_utils-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3857837ebb95e15c8264854b946554496faf4c0be8bac0cfb67f466a3710ef70 |
|
MD5 | c0a316429ab6b73b3aaffea826214985 |
|
BLAKE2b-256 | 61ca175e09803d40315ef7f3c9e68923d372a8e2a56a1ee34e816cbbae86eac8 |