Python Django Celery implements asynchronous tasks (2) using rabbitmq as broker

In the previous article, Python Celery implemented asynchronous tasks by using Django as the default borker (message distribution), because after upgrading the latest celery, Django is no longer supported as a borker, so the test platform was replaced with rabbitmq. The following is a brief introduction to the replacement method, which is actually very simple.

Under the django project, modify the following code in the global settings.py

 # 使用rabbitmq 作为任务代理 (broker)
BROKER_URL = "amqp://" 

# 默认是以本机的mq服务作为broker。如果你需要配置成远程的mq,请填写完整的
BROKER_URL = amqp://userid:password@hostname:port/virtual_host

There are many installation methods of rabbitmq on the Internet, please install it after Google, and start the mq service.

Structure diagram

write picture description here


celey structure

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325472632&siteId=291194637