Workaround for celery task priority on RabbitMQ?

房东的猫 提交于 2019-11-30 05:12:46
Rajs123

Apart from this, you can push urgent tasks to some queue (let's say urgent-queue) and set consumer priorities, i.e, let all consumers pick up task from urgent-queue with high priority.

https://github.com/celery/celery/issues/3098

At consumer end, you can define x-priority argument in queues to consume from. In the below example, consumer picks up tasks from celery queue with priority 0 and from hipri with priority 10.

Example:

CELERY_QUEUES = (
    Queue('celery', Exchange('celery', type='direct'), routing_key='celery',
          consumer_arguments={'x-priority': 0}),
    Queue('hipri', Exchange('hipri', type='direct'), routing_key='hipri',
          consumer_arguments={'x-priority': 10}),
)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!