Reputation: 94
Is it possible to consume messages from rabbitmq using celery in django?
Messages are being sent from a different non-django app
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
app = Celery("test")
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.task_routes = {
'task.send_emails':{
'queue': 'sendmail',
'exchange': 'sendmail',
'routing_key': 'sendmail'
}
}
app.config_from_object('django.conf:settings')
Upvotes: 1
Views: 126
Reputation: 948
The messages that Celery creates contain the name of the method to be executed and it's parameter list - so no, Celery itself can't consume messages that weren't created in that format for existing, registered Celery tasks.
However, you can use Kombu to achive that - it's part of celery that handles raw message creation and consumption and it's quite easy to use.
Upvotes: 2