一、应用场景
celery 进行多任务多队列操作时,出现的此错误
kombu.exceptions.OperationalError:
Cannot route message for exchange 'celery_task': Table empty or key no longer exists.
Probably the key ('_kombu.binding.celery_task') has been removed from the Redis database.
二、解决办法
https://github.com/uktrade/data-hub-api/pull/2143
本人的原因
任务队列broker和执行结果backend 均为redis, 然而路由却用了rabbitmq的交换机,所以报错
BROKER_URL = 'redis://:123456@localhost:6379/3'
CELERY_RESULT_BACKEND = 'redis://:123456@localhost:6379/4'
celery路由配错了
CELERY_ROUTES= {
- 正确
'celery_practice.semi_auto_task': {'queue': 'celery_task', 'routing_key': 'semi_auto_task', 'priority': 7},
- 错误
'celery_practice.semi_auto_task': {'exchange': 'celery_task', 'routing_key': 'semi_auto_task', 'priority': 7},
}