Example #1
0
 /**
  * Convenience method that registers consumer and then starts client event loop.
  *
  * @param callable $callback
  * @param string $queue
  * @param string $consumerTag
  * @param bool $noLocal
  * @param bool $noAck
  * @param bool $exclusive
  * @param bool $nowait
  * @param array $arguments
  */
 public function run(callable $callback, $queue = "", $consumerTag = "", $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
 {
     $response = $this->consume($callback, $queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
     if ($response instanceof MethodBasicConsumeOkFrame) {
         $this->client->run();
     } elseif ($response instanceof PromiseInterface) {
         $response->then(function () {
             $this->client->run();
         });
     } else {
         throw new ChannelException("Unexpected response of type " . gettype($response) . (is_object($response) ? " (" . get_class($response) . ")" : "") . ".");
     }
 }