要求:Django 使用 RabbitMQ(Internal) 和 SQS/Kafka
这两个任务共享通用的 DB/Django 模型。
截至 2016 年 10 月,Django 设置仅支持一种代理配置
如何使用不同的队列配置和代理设置共享任务?
最佳答案
from __future__ import absolute_import
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
app = Celery('proj', broker=["redis://redis:6379/0", "redis://192.168.99.100:6379/0", "redis://192.168.99.102:6379/0"])
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
关于django - 如何在 Django 和 Celery 中配置多个代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40211852/