|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-06-10 15:34 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-06-10 15:34 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 01:00:01 2025 UTC |
Description: ------------ PHP 5.3.3-1ubuntu9.10 with Suhosin-Patch (cli) (built: Feb 11 2012 06:40:29) amqp - 1.0.1 Description: My queue gets deleted when I call AMQPQueue::nack <?php /** * Consume */ //create connection $resConnection = new AMQPConnection(array( 'host' => 'localhost' , 'vhost' => '/the_programmer' , 'port' => '5672' , 'login' => 'admin' , 'password' => 'admin' )) ; try { //connect to server $resConnection->connect() ; //create an amqp channel $resChannel = new AMQPChannel($resConnection) ; /** * Create an exchange - please refer to the rabbitmq documentation about exchanges * * - it will create a new exchange with the given parameters if such an * exchange does not exist or it will bind itself to an existing it one if one * already exist. */ $resExchange = new AMQPExchange($resChannel) ; $resExchange->setName('async_exchange') ; $resExchange->setType(AMQP_EX_TYPE_DIRECT) ; $resExchange->setFlags(AMQP_AUTODELETE) ; $resExchange->declare() ; /** * Create a queue - please refer to the rabbitmq documentation about queues * * - it will create a new queue with the given parameters if such a * queue does not exist or it will bind itself to an existing it one if one * already exist. */ $resQueue = new AMQPQueue($resChannel) ; $resQueue->setName('my_queue') ; $resQueue->setFlags(AMQP_DURABLE) ; $resQueue->setArguments(array('x-dead-letter-routing-key' => 'async.dead' , //'x-message-ttl' => 6000, 'x-dead-letter-exchange' => 'async_dead')) ; $resQueue->declare() ; $resQueue->bind('async_exchange' , 'async.key') ; $objMessage = $resQueue->get() ; if ($objMessage) { //process message print $objMessage->getBody() ; $resQueue->nack($objMessage->getDeliveryTag()) ; } } catch (AMQPException $e) { echo $e->getMessage() ; } catch (AMQPConnectionException $e) { echo $e->getMessage() ; } catch (AMQPExchangeException $e) { echo $e->getMessage() ; } ?>