2

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

Scherbius.com
  • 3,396
  • 4
  • 24
  • 44

2 Answers2

1

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

Charles
  • 50,943
  • 13
  • 104
  • 142
klkvsk
  • 670
  • 4
  • 7
  • thanks, looks like I missed that setFlag currently considers only 2 types of flags... – Scherbius.com Aug 01 '13 at 16:18
  • 1
    This link is broken. Try [AMQPExchange::setFlags()](http://php.net/manual/pl/amqpexchange.setflags.php) and [AMQPQueue::setFlags()](http://php.net/manual/pl/amqpqueue.setflags.php) – vladkras Jun 28 '16 at 08:03
0

I'm having the same problem. Exchanges with auto-delete cannot be created using current php amqp module (v1.2.0).

There is recent commit in dev-master (1.4.0-dev) that is adding this functionality. Still, I was not able to make it work. I see that exchange object is having auto_delete attribute, but when it is declared, in rabbitmq (v3.1.3) it is having auto_delete flag set to false.

For now I will create cronjob, that will delete exchanges that don't have related queue.

This is answer for your question and also collaboration request. Any input about this topic is welcome.

wormhit
  • 3,687
  • 37
  • 46