django芹菜rabbitmq问题:"警告/ MainProcess]收到并删除未知消息。错误的目的地"

时间:2016-02-11 19:04:15

标签: django celery django-celery

我的settings.py

CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml', 'pickle', 'application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_RESULT_BACKEND = 'djcelery.backends.cache:CacheBackend'

celery.py代码

from __future__ import absolute_import
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webapp.settings')
from django.conf import settings  
app = Celery('webapp')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


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

tasks.py代码

from __future__ import absolute_import
from celery.utils.log import get_task_logger
from celery import shared_task
import datetime

logger = get_task_logger(__name__)

@shared_task
def sample_code():
    logger.info("Run time:" + str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")))
    return None

在shell上我导入并运行为" sample_code.delay()"

完整错误堆栈:

[2016-02-12 00:28:56,331: WARNING/MainProcess] Received and deleted unknown message. Wrong destination?!?

The full contents of the message body was: body: '\x80\x02}q\x01(U\x07expiresq\x02NU\x03utcq\x03\x88U\x04argsq\x04]q\x05U\x05chordq\x06NU\tcallbacksq\x07NU\x08errbacksq\x08NU\x07tasksetq\tNU\x02idq\nU$f02e662e-4eda-4180-9af4-2c8a1ceb57c4q\x0bU\x07retriesq\x0cK\x00U\x04taskq\rU$app.tasks.sample_codeq\x0eU\ttimelimitq\x0fNN\x86U\x03etaq\x10NU\x06kwargsq\x11}q\x12u.' (232b)
{content_type:u'application/x-python-serialize' content_encoding:u'binary'
  delivery_info:{'consumer_tag': u'None4', 'redelivered': False, 'routing_key': u'celery', 'delivery_tag': 8, 'exchange': u'celery'} headers={}}

请告诉我错误的地方

1 个答案:

答案 0 :(得分:1)

为我解决的方法是改变运行芹菜的命令

它给出了问题:

celery -A <app_path> worker --loglevel=DEBUG

但是如果我们使用它,它会毫无问题地运行:

celery -A <app_path> worker -l info

如果他们遇到同样的问题,可能对其他人有帮助。