如何在Django和Celery中配置多个代理?

问题描述 投票:5回答:1

[要求:Django使用RabbitMQ(Internal)和SQS / Kafka这两个任务共享通用的DB / Django模型。

[Django设置自2016年10月起仅支持一种代理配置

如何使用不同的队列配置和代理设置共享任务?

django celery amazon-sqs django-celery django-settings
1个回答
0
投票
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()

© www.soinside.com 2019 - 2024. All rights reserved.