DEV Community

Deepak Singh
Deepak Singh

Posted on

How to Work with Celery in Django using TLS RabbitMQ configuration

I want to know if celery supports TLS enabled RabbitMQ configuration?

and if yes then how we can make it work or any workaround possible

I have tried by using below source in my file of my Django application

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
import ssl

os.environ.setdefault('DJANGO_SETTINGS_MODULE', '<app_name>.settings')
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

app = Celery('<app_name>')

app.conf.broker_use_ssl = {
  'keyfile': '<path>/client_key.pem',
  'certfile': '<path>/client_certificate.pem',
  'ca_certs': '<path>/ca_certificate.pem',
  'cert_reqs': ssl.CERT_REQUIRED
app.conf.broker_url = 'amqps://'

app.conf.broker_login_method = 'EXTERNAL'
Enter fullscreen mode Exit fullscreen mode

through the above code I am able to connect to the rabbitMQ server
but background tasks are not processing

I highly appreciate your help onto this

Top comments (0)