celery-php icon indicating copy to clipboard operation
celery-php copied to clipboard

BUG: fix exchange routing

Open marek-mazur opened this issue 9 years ago • 2 comments

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 !!!
);

marek-mazur avatar Feb 01 '16 10:02 marek-mazur

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.

lexabug avatar Jan 15 '18 17:01 lexabug

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.

marek-mazur avatar Jan 15 '18 20:01 marek-mazur