AMQP 1.0.0: AMQPExchangeException when receiving signal

From: Date: Fri, 17 Feb 2012 22:26:52 +0000
Subject: AMQP 1.0.0: AMQPExchangeException when receiving signal
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9142@lists.php.net to get a copy of this message
Hello Everybody, I have been playing with the AMQP 1.0.0 extension. I am seeing the following behavior that I find surprising, but I am not sure whether it is a bug, and if yes in which project (PHP, AMQP extension or rabbitmq-c). $ uname -a > Linux ip-XXX 2.6.32-317-ec2 #36-Ubuntu SMP Fri Jul 8 18:12:30 UTC 2011 > x86_64 GNU/Linux $ cat /etc/lsb-release > DISTRIB_ID=Ubuntu > DISTRIB_RELEASE=10.04 > DISTRIB_CODENAME=lucid > DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS" $ php -v > PHP 5.3.10 (cli) (built: Feb 17 2012 11:22:03) > Copyright (c) 1997-2012 The PHP Group > Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies $ php -i | grep -i configure > Configure Command => './configure' '--prefix=/home/pierre/' > '--enable-pcntl' $ pear list -c pecl > INSTALLED PACKAGES, CHANNEL PECL.PHP.NET: > ========================================= > PACKAGE VERSION STATE > amqp 1.0.0 stable This is the script: <?php > pcntl_signal_dispatch(); > global $run; > $run = true; > function sig_handler($sig) { > global $run; > switch($sig) { > case SIGUSR1: > case SIGTERM: > case SIGINT: > echo "SIG".PHP_EOL; > $run = false; > break; > } > } > pcntl_signal(SIGUSR1, "sig_handler"); > pcntl_signal(SIGTERM, "sig_handler"); > pcntl_signal(SIGINT, "sig_handler"); > $con = new AMQPConnection(); > $con->connect(); > $channel = new AMQPChannel($con); > $ex = new AMQPExchange($channel); > $ex->setName("exchange1"); > $ex->setType(AMQP_EX_TYPE_FANOUT); > $ex->declare(); > $q = new AMQPQueue($channel); > $q->setName("queue-test"); > $q->declare(); > $q->bind('exchange1', 'routing.key'); > $msg_template = "test"; > try { > $i = 0; > while($run) { > $msg = $i." - ".$msg_template; > $ex->publish($msg, 'routing.key', 0 /* default */, > array('delivery_mode' => 2)); > $i++; > } > } > catch (Exception $e) { > var_dump($e); > } > $con->disconnect(); > ?> After starting it and getting its pid, I run: kill -s SIGUSR1 <pid> And I get the following exception: object(AMQPExchangeException)#5 (7) { > ["message":protected]=> > string(0) "" > ["string":"Exception":private]=> > string(0) "" > ["code":protected]=> > int(0) > ["file":protected]=> > string(28) "/home/pierre/publisher.php" > ["line":protected]=> > int(39) > ["trace":"Exception":private]=> > array(1) { > [0]=> > array(6) { > ["file"]=> > string(28) "/home/pierre/publisher.php" > ["line"]=> > int(39) > ["function"]=> > string(7) "publish" > ["class"]=> > string(12) "AMQPExchange" > ["type"]=> > string(2) "->" > ["args"]=> > array(4) { > [0]=> > string(13) "191395 - test" > [1]=> > string(11) "routing.key" > [2]=> > int(0) > [3]=> > array(1) { > ["delivery_mode"]=> > int(2) > } > } > } > } > ["previous":"Exception":private]=> > NULL > } Instead of the exception I would expect the current loop iteration to finish and break out of it and disconnect from the AMQP server. So, is this a bug or am I misunderstanding something? Thank you. Pierre

« previous php.pecl.dev (#9142) next »