How to post a task on a celery-rabbitmq queue in PHP? How to post a task on a celery-rabbitmq queue in PHP? php php

How to post a task on a celery-rabbitmq queue in PHP?


By default, your PHP client for Celery takes the queue name as "celery".

In order to change the queue to publish to, you must specify the queue name while instantiating a connection to Celery. So, if you are starting your Celery worker with "-Q demo" option, then your connection to Celery in PHP should be -

$exchange = 'demo'; $binding = 'demo'; $c = new Celery('localhost', 'guest', 'guest', '/', $exchange, $binding); 

Note: With -Q option, the exchange and routing_key value is same as queue_name.

Please try this and share the results.

About exchange and binding :

With analogy to Telephone Services, Exchange is like "Telephone Operator", whose only job is to "Direct the call to YOU" with the help of routing_key.

Binding is then "Your Telephone Number", which acts as routing_key to your telephone.

Note : This process where exchange is redirecting the incoming message to the queue based on binding (routing_key), is a DIRECT exchange type. AMQP has few other types of exchanges, which you can read in AMQP documentation.

You can also refer this Celery page