Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-rabbitmq-utils-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

django_rabbitmq_utils-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file django-rabbitmq-utils-0.0.1.tar.gz.

File metadata

  • Download URL: django-rabbitmq-utils-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for django-rabbitmq-utils-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9edf5d34a80973fc2f39974a13b7f86770aac5b698a2d2f138c609d6d3c39bee
MD5 c3a8b6a00421fbd72709016468f193bb
BLAKE2b-256 7f9233add929953619ff709a7bad3076bff20ee3961bc1cbad4646ca0c64a7fb

See more details on using hashes here.

File details

Details for the file django_rabbitmq_utils-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_rabbitmq_utils-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3857837ebb95e15c8264854b946554496faf4c0be8bac0cfb67f466a3710ef70
MD5 c0a316429ab6b73b3aaffea826214985
BLAKE2b-256 61ca175e09803d40315ef7f3c9e68923d372a8e2a56a1ee34e816cbbae86eac8

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