[Django]-Celery, route all tasks in a Django project to a specific queue

4👍

At the end it was easier than I expected. I just had to set up both the default queue and the default routing key (and optionally the default exchange, as long as it’s a direct exchange).

CELERY_DEFAULT_QUEUE = 'q2'
CELERY_DEFAULT_EXCHANGE = 'q2'
CELERY_DEFAULT_ROUTING_KEY = 'q2'

I had some concepts unclear, but after following the official RabbitMQ’s tutorials they got much clearer and I was able to fix the problem.

3👍

You can define the task routing as

CELERY_ROUTES = {
    'services.qosservice.*': {'queue': 'qos_celery'},
}

The * is the celery-supported wildcard.

Reference: http://docs.celeryproject.org/en/latest/userguide/routing.html#automatic-routing

👤Yoga

0👍

I think you must define rouing in settings.py

CELERY_ROUTES = {

    'services.qosservice.set_qos_for_vm': {'queue': 'qos_celery'},

    'services.qosservice.qos_recovery': {'queue': 'qos_celery'},

    'services.qosservice.qos_recovery_compute': {'queue': 'qos_celery_1'},

}

In my exmaple. task set_qos_for_vm will be routing to qos_celery queue and task qos_recovery_compute queue will be routing to qos_celery_1.

More detail: http://docs.celeryproject.org/en/latest/userguide/routing.html#id2

Hope it help you

Leave a comment