[英]Celery Why Does Task Stay In Queue
So I am using Celery with RabbitMQ. 所以我在使用带有RabbitMQ的Celery。 I have a RESTful API that registers a user.
我有一个注册用户的RESTful API。 I am using remote Celery worker to send a registration email asynchronously so my API can return fast response.
我正在使用远程Celery工作程序异步发送注册电子邮件,以便我的API可以快速响应。
from .tasks import send_registration_email
def register_user(user_data):
# save user to the database etc
send_registration_email.delay(user.id)
return {'status': 'success'}
This works fine. 这很好用。 Email is being sent in a non blocking asynchronous way (and can be retried if fails which is cool).
电子邮件以非阻塞异步方式发送(如果失败则可以重试,这很酷)。 The problem is when I look at RabbitMQ management console.
问题是当我查看RabbitMQ管理控制台时。 I can see that the send_registration_email has created a random queue.
我可以看到send_registration_email创建了一个随机队列。 Something like:
就像是:
I can see that the task has been successfully executed. 我可以看到该任务已成功执行。 So why does the random queue stays in RabbitMQ forever?
那么为什么随机队列永远留在RabbitMQ中呢? This is the task payload:
这是任务有效负载:
{"status": "SUCCESS", "traceback": null, "result": true, "task_id": "aad10877-3508-4179-a5fb-99f1bd0b8b2f", "children": []}
This normal behaviour, if you have configured CELERY_RESULT_BACKEND in your settings. 如果您在设置中配置了CELERY_RESULT_BACKEND,则会出现这种正常行为。 Please check here: Celery result backend description
请在这里查看: 芹菜结果后端描述
You could disable result backend, or decrease each message life time. 您可以禁用结果后端,或减少每个消息的生命周期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.