I am trying to let consumer listen to all queues in nameless exchange in consumer.php but i have to mention queue names as shown:
$this->channel->basic_consume('Cancelcontact', '', false, false, false, false, array($this, 'processMsg'));
$this->channel->basic_consume('Acceptcontact', '', false, false, false, false, array($this, 'processMsg'));
$this->channel->basic_consume('Declinecontact', '', false, false, false, false, array($this, 'processMsg'));
Is there any way to get names of all queues in channel and write single basic consume for same purpose??
Even if it is possible, it is a bad idea.
Having multiple queues allows you to have multiple consumers, each of which can handle a particular type of message. By having all of your queues go to the same consumer, your code will have to check the type of message to figure out what to do with it.
This is a duplication of the work that RabbitMQ has already done for you, and may put you in the mode of "Selective Consumer" - an anti-pattern in RabbitMQ.
The process of handling an AcceptContact
or CancelContact
message will be different. Therefore, the code that handles these messages will be different.
Have the code that handles AcceptContact
messages only consume from the AcceptContact
queue. Have the code that can handle CancelContact
messages only consume from the CancelContact
queue.