DEV Community

Deepak Singh
Deepak Singh

Posted on

3 2

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 celery.py 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://rabbitmq.example.com:5671/vhostname'

app.conf.broker_login_method = 'EXTERNAL'
app.autodiscover_tasks()
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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs