conn = $conn; $this->routing = $routing; $this->logger = $logger; $this->autoDeclare = $autoDeclare; if ($conn->connectOnConstruct()) { $this->getChannel(); } } public function __destruct() { $this->close(); } public function close() { if ($this->ch) { try { $this->ch->close(); } catch (\Exception $e) { // ignore on shutdown } } if ($this->conn && $this->conn->isConnected()) { try { $this->conn->close(); } catch (\Exception $e) { // ignore on shutdown } } } public function renew() { if (!$this->conn->isConnected()) { return; } $this->conn->reconnect(); } /** * @return AMQPChannel */ public function getChannel() { if (empty($this->ch) || null === $this->ch->getChannelId()) { $this->ch = $this->conn->channel(); } return $this->ch; } }