django celery rabbitmq issue: “WARNING/MainProcess] Received and deleted unknown message. Wrong destination”

See original GitHub issue

My 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 code

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 code [ 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](url) On shell I am importing and running as “sample_code.delay()”

Full error stack:

[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={}}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
yiweigcommented, Mar 3, 2021

Hello from 2021! I also ran into this issue when trying to integrate Celery with custom consumers into an existing Flask app (I know this is a django repo, but the bug was identical to my situation).

For anyone else who comes across this thread, my problem was exactly the same as @pawaramol22’s above: after setting up my Celery app and my custom consumer following the docs, I noticed that every other message would raise the Wrong destination error. I tried applying the --without-heartbeat --without-gossip --without-mingle flags to my startup command, but that did not work for me.

What ended up working was something similar to @viveksyngh’s comment from above. I wasn’t specifying any queue options via -Q in my celery -A .. worker command, but I was using the task_queues option within my Python config:

celery.py

app = Celery()
app.config_from_object(config)

config.py:

..
task_queues = [ .. ]
..

By removing the task_queues option everything started working fine again. I wrote a test script that sent 10k messages to my custom consumer and all of them were consumed without issues.

Hope this helps anyone looking for a solution in the future!

1reaction
pawaramol22commented, Jul 14, 2017

I was using custom consumer and I ran into bug celery version we were using where it was ignoring --without-heartbeat --without-gossip --without-mingle. We had to customize celery project to use these args. Latest version celery (think its 4) should have this fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Celery &Redis:WARNING/MainProcess] Received...anycodings
Celery &Redis:WARNINGMainProcess] Received and deleted unknown message. Wrong destination. Questions : Celery &Redis:WARNINGMainProcess] Received and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found