celery-php
celery-php copied to clipboard
BUG: fix exchange routing
Creating tasks with custom routing key, when RabbitMq is empty should pass this parameter to bind properly newly created queue. But currently is not, so starting php apllication (before backend with celery) declares new exchange and queue with improper binding. In effect of that all new sent task are lost.
Example:
$celery = new Celery(...);
$taskName = 'someTaskName';
$taskData = ['lorem' => 'ipsum'];
$asyncResult = false;
$routingKey = 'someRoutingKey';
$celery->PostTask($taskName, $taskData, $asyncResult, $routingKey);
AMQPLibConnector.php
$ch->queue_bind(
$details['binding'], /* queue name - "celery" */
$details['exchange'], /* exchange name - "celery" */
$details['routing_key'] // <--- Lost parameter !!!
);
AFAIK Python's Celery binds queues to exchanges using queue names as default routing key. When a task is posted to a broker a routing key may vary, which can lead it to different queues although it posted to the same exchange. Ideally, I think that all binding should be declared before posting any task to a queue and shouldn't be a part of the postTask()
method.
See my pull request here https://github.com/gjedeer/celery-php/pull/112.
Sure. But without that you cannot autocreate new queue on empty Rabbit. I think it should be possible with this lib as it is possible in python.