* Tell the server you are going to stop consuming * It will finish up the last message and not send you any more */ public function stop() { echo 'Stopping consumer by cancel command.' . PHP_EOL; // this gets stuck and will not exit without the last two parameters set $this->_channel->basic_cancel($this->_tag, false, true); } /** * Current connection * * @var PhpAmqpLib\Connection\AMQPSSLConnection */ protected $_connection = null; /** * Current channel * * @var PhpAmqpLib\Channel\AMQPChannel */ protected $_channel = null; /** * Consumer tag * * @var string */ protected $_tag = 'consumer'; } $consumer = new Consumer(); $consumer->start();