/** * Get a channel with the connection $connection * * @param Connection $connnection Connection to use * @return AMQPChannel */ private function getChannel(Connection $connection) { $name = $connection->getName(); if (isset($this->channels[$name])) { return $this->channels[$name]; } try { $connection = new AMQPConnection(['host' => $connection->getHost(), 'port' => $connection->getPort(), 'login' => $connection->getLogin(), 'password' => $connection->getPassword(), 'vhost' => $connection->getVhost()]); $connection->connect(); return $this->channels[$name] = new AMQPChannel($connection); } catch (AMQPException $e) { throw new MessagingException($e); } }
/** @return AMQPLazyConnection */ private function getConnection(Connection $connection) { $name = $connection->getName(); if (isset($this->connections[$name])) { return $this->connections[$name]; } $connection = new AMQPLazyConnection($connection->getHost(), $connection->getPort(), $connection->getLogin(), $connection->getPassword(), $connection->getVhost()); $connection->set_close_on_destruct(true); return $this->connections[$name] = $connection; }