查找 RabbitMQ BROKER_URL
Find RabbitMQ BROKER_URL
这个问题可能太明显了,但这是我第一次使用 Celery 和 RabbitMQ 或类似的东西。我需要在某处声明我的 BROKER_URL
,但我什至不知道如何找到它.. 它在哪里?在终端上我写 sudo rabbitmq-server
,我可以看到 rabbitmq 是 运行。
我假设您已经遵循了 Celery First Steps with Django tutorial. The structure provided by that tutorial (and specifically the line app.config_from_object('django.conf:settings')
) in celery.py
configures Celery to read its settings from the Django configuration. So, any Celery settings, like BROKER_URL
, CELERY_RESULT_BACKEND
, or others 可以简单地通过将它们包含在 Django 项目的 settings.py
文件中进行配置。
然而,这可能都是无关紧要的! 正如 documentation for the BROKER_URL parameter indicates, "[the] transport part [of the URL] is the broker implementation to use, and the default is amqp...", and as the documentation for the underlying messaging library (Kombu) 所述,“[a] 不带选项的连接将使用默认连接设置,即使用localhost
主机、默认端口、用户名 guest
、密码 guest
和虚拟主机“/”。
这一切意味着什么?简而言之,它应该开箱即用,假设你是 运行 RabbitMQ,与你的 Celery 项目在同一台计算机上,并且假设你没有更改 RabbitMQ 的设置(即端口号、身份验证等)。 ).如果没有 BROKER_URL
设置,Celery 将使用其默认设置,即使用默认 guest
凭据连接到同一台计算机上的 AMQP 服务器(即 RabbitMQ)。
这个问题可能太明显了,但这是我第一次使用 Celery 和 RabbitMQ 或类似的东西。我需要在某处声明我的 BROKER_URL
,但我什至不知道如何找到它.. 它在哪里?在终端上我写 sudo rabbitmq-server
,我可以看到 rabbitmq 是 运行。
我假设您已经遵循了 Celery First Steps with Django tutorial. The structure provided by that tutorial (and specifically the line app.config_from_object('django.conf:settings')
) in celery.py
configures Celery to read its settings from the Django configuration. So, any Celery settings, like BROKER_URL
, CELERY_RESULT_BACKEND
, or others 可以简单地通过将它们包含在 Django 项目的 settings.py
文件中进行配置。
然而,这可能都是无关紧要的! 正如 documentation for the BROKER_URL parameter indicates, "[the] transport part [of the URL] is the broker implementation to use, and the default is amqp...", and as the documentation for the underlying messaging library (Kombu) 所述,“[a] 不带选项的连接将使用默认连接设置,即使用localhost
主机、默认端口、用户名 guest
、密码 guest
和虚拟主机“/”。
这一切意味着什么?简而言之,它应该开箱即用,假设你是 运行 RabbitMQ,与你的 Celery 项目在同一台计算机上,并且假设你没有更改 RabbitMQ 的设置(即端口号、身份验证等)。 ).如果没有 BROKER_URL
设置,Celery 将使用其默认设置,即使用默认 guest
凭据连接到同一台计算机上的 AMQP 服务器(即 RabbitMQ)。