我想路由2个不同的Celery_BROKER_URL

发布于 2025-02-12 13:23:31 字数 757 浏览 1 评论 0原文

我想将2种不同的芹菜broker_url用于2个不同的IP,并且特定任务应在另一个URL中进行(ex -redis://127.0.0.2:6379)。

环境文件

CELERY_TASK_TRACK_STARTED=True
CELERY_BROKER_URL="redis://127.0.0.1:6379"

芹菜.py

import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'engine.settings')

app = Celery('engine')
app.config_from_object('django.conf:settings')

# Enable sending the "task-sent" notification.
app.conf.task_send_sent_event=True

app.conf.database_engine_options = {'echo': True}

# load task modules from all registered Django app configs.
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))

I want to use 2 different CELERY_BROKER_URL for 2 different IP's and specific task should go in the another URL (ex - redis://127.0.0.2:6379).

environment file

CELERY_TASK_TRACK_STARTED=True
CELERY_BROKER_URL="redis://127.0.0.1:6379"

celery.py

import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'engine.settings')

app = Celery('engine')
app.config_from_object('django.conf:settings')

# Enable sending the "task-sent" notification.
app.conf.task_send_sent_event=True

app.conf.database_engine_options = {'echo': True}

# load task modules from all registered Django app configs.
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文