/** * @return void */ public function run() { $this->connector->connect(); $this->connector->defineQoS(1); $this->connector->basicConsume($this->requestsQueue, $this->getCallback()); while (count($this->connector->getChannelCallbacks())) { $this->logger->debug('Waiting...'); $this->connector->wait(); } $this->connector->closeConnection(); }
/** * @throws \Exception */ public function run() { $this->numberOfReceivedMessages = 0; try { // Connect $this->connector->connect(); // Start consuming $this->connector->basicConsume($this->queue, $this->getCallback()); while (0 < count($this->connector->getChannelCallbacks())) { $this->connector->wait(); } // Close connection $this->connector->closeConnection(); } catch (ConnectorException $e) { $this->logger->warning($e->getMessage()); // Try reconnection $this->connector->connect(true); } catch (\ErrorException $e) { $this->logger->warning($e->getMessage()); // Try reconnection $this->connector->connect(true); } catch (\Exception $e) { $this->logger->error($e->getMessage()); throw $e; } }