Search code examples
phprabbitmqamqpphp-amqp

RabbitMq: Setting AMQP_AUTODELETE flag on Exchange with PHP AMQP


I'm trying to set AMQP_AUTODELETE flag on my exchange using AMQPExchange::setFlags ( int $flags )

http://php.net/manual/en/amqp.constants.php http://www.php.net/manual/en/amqpexchange.setflags.php

does not work... :(

$exchange = new \AMQPExchange(new \AMQPChannel($this->_connection));

$exchange->setName($name);
$exchange->setType(AMQP_EX_TYPE_FANOUT);

$exchange->setFlags(AMQP_AUTODELETE);
$exchange->declare();

$exchange->getFlags() returns 0 instead of 16 (integer value of AMQP_AUTODELETE).

But it works when I set AMQP_DURABLE flag the same way, $exchange->getFlags() returns 2.

Has anyone found a solution for this ? Thanks!!!


Solution

  • AMQP_AUTODELETE flag can only be used for AMQPQueue. See the AMQPExchange::setFlags manual page for valid flags.