Is true that on Celery there is a bit of confusion when you go to Queues, one thing you must keep in mind is that queue parameter refers to a Celery Kombu Queue Object and not directly to a AMQP queue, you can understand this by reading this extract from the docs.
Of course the fact that celery creates the queue and exchange with the same name is the origin of confusion of the usage of queue parameter.
Always in the docs you can read this paragraph:
If you have another queue but on another exchange you want to add, just specify a custom exchange and exchange type:
CELERY_QUEUES = (
Queue('feed_tasks', routing_key='feed.#'),
Queue('regular_tasks', routing_key='task.#'),
Queue('image_tasks', exchange=Exchange('mediatasks', type='direct'),
routing_key='image.compress'),
)
So in this way you could bind 2 different queue on the same exchange.
After to route the task using only the exchange and the key you could use Routers class
class MyRouter(object):
def route_for_task(self, task, args=None, kwargs=None):
if task == 'myapp.tasks.compress_video':
return {'exchange': 'video',
'exchange_type': 'topic',
'routing_key': 'video.compress'}
return None
More here http://celery.readthedocs.org/en/latest/userguide/routing.html#routers
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…