I'm updating my celery workers from celery v3 to celery v4, and all my tasks are Class Based Tasks. I have manually registered the tasks since it's what indicated in the upgrade doc.
The problem is in task routing, I have the following Task:
class RegisterTask(Task):
routing_key = 'app_server.register'
def run(**params):
whatever ...
I'm running two celery workers, one on the default queue, and the other on the register queue, like below:
# Default Worker
celery -A app_server worker --loglevel=info --concurrency=1
# Register Worker
celery -A app_server worker -Q app_server_register --loglevel=info --concurrency=1
and here's my queues definition:
CELERY_TASK_DEFAULT_QUEUE = 'app_server_default'
CELERY_TASK_DEFAULT_ROUTING_KEY = 'app_server.default'
CELERY_TASK_QUEUES = (
Queue('app_server_default', routing_key='app_server.default'),
Queue('app_server_register', routing_key='app_server.register')
)
The unexpected behavior is the difference I see when I call the task using Celery V3 and Celery V4.
# Celery V3
RegisterTask().delay(**params)
# task is consumed by the register worker!
# Celery V4
RegisterTask().delay(**params)
# task is consumed by the default worker!
And I want the task to be consumed by the register worker (celery v3 behavior), hence why I hardcoded the routing_key attribute in the class based task. But Celery V4 seems to ignore the routing_key attribute in the class based task.
[I'm also using redis as the broker, if it's any important]
Any Ideas on this issue?
Thanks!