擅长:python、mysql、java
<p>要动态链接到不同的队列,请执行以下步骤:</p>
<p>1)用'queue'属性指定队列的名称<br/></p>
<pre><code>celery.send_task('job1', args=[], kwargs={}, queue='queue_name_1')
celery.send_task('job1', args=[], kwargs={}, queue='queue_name_2')
</code></pre>
<p>(此处特定作业使用两个队列)</p>
<p>2)在配置文件中添加以下条目</p>
<pre><code>CELERY_CREATE_MISSING_QUEUES = True
</code></pre>
<p>3)启动工作进程时,使用-Q指定要从中使用作业的队列名称</p>
<pre><code>celery -A proj worker -l info -Q queue1
celery -A proj worker -l info -Q queue2
</code></pre>