/** * Reconnect amqp connection */ public function reconnect() { if (!$this->amqpConnection->isConnected()) { $this->amqpConnection->reconnect(); $this->channel = $this->amqpConnection->channel(); $this->declaredQueues = []; } }
/** * @param bool $forceReconnection * * @return void */ public function connect($forceReconnection = false) { $useSslConnection = !empty($this->sslOptions); $env = ['server' => $this->server, 'port' => $this->port, 'vhost' => $this->vhost, 'ssl' => $useSslConnection]; if (true == $forceReconnection || false == $this->connection instanceof AMQPStreamConnection) { $this->logger->debug('Stablishing connection...', $env); if ($useSslConnection) { $this->connection = new AMQPSSLConnection($this->server, $this->port, $this->user, $this->pass, $this->vhost, $this->sslOptions); } else { $this->connection = new AMQPStreamConnection($this->server, $this->port, $this->user, $this->pass, $this->vhost); } $this->logger->info('Connection stablished!', $env); } elseif (false == $this->connection->isConnected()) { $this->logger->debug('Restablishing connection...', $env); $this->connection->reconnect(); $this->logger->info('Connection restablished!', $env); } $this->openChannel($forceReconnection); }
public function isConnected() { return $this->connection->isConnected(); }