#abmp.py:
from celery import Celery
app = Celery('abmp',
backend='amqp://guest@localhost',
broker='amqp://guest@localhost'
)
@
app.task(bind=True)
def add(self, a, b):
return a + b
# execute_test.py
from abmp import add
result = add.apply_async(
args=(5,7),
queue='push_tasks',
exchange='push_tasks',
routing_key='push_tasks'
)
#后台执行
celery -A abmp worker -E -Q push_tasks -l info
最后到 rabbitmq 后台查看,发现每次执行 execute_test.py 都生成了一个新的 queue,而不是把任务丢给 push_tasks 中。