private function declareQueue($type)
 {
     if (isset($this->declaredQueue[$type])) {
         return;
     }
     $exchangeName = $this->getExchangeName($type);
     $queueName = $this->getQueueName($type);
     $this->channel->exchange_declare($exchangeName, 'direct');
     $this->channel->queue_declare($queueName, false, false, false, false);
     $this->channel->queue_bind($queueName, $exchangeName);
     $this->declaredQueue[$type] = true;
 }
 /**
  * Initialize connection, queue and exchange
  *
  * @return void
  */
 protected function initConnection()
 {
     // Only initialize once
     if ($this->connection) {
         return;
     }
     $this->connection = new AMQPStreamConnection($this->connectionConfig['host'], $this->connectionConfig['port'], $this->connectionConfig['user'], $this->connectionConfig['password'], $this->connectionConfig['vhost']);
     $this->channel = $this->connection->channel();
     if ($this->declaredQueue) {
         $this->channel->queue_declare($this->queueConfig['name'], $this->queueConfig['passive'], $this->queueConfig['durable'], $this->queueConfig['exclusive'], $this->queueConfig['autoDelete']);
     }
     $this->channel->exchange_declare($this->exchangeConfig['name'], $this->exchangeConfig['type'], $this->exchangeConfig['passive'], $this->exchangeConfig['durable'], $this->exchangeConfig['autoDelete']);
     if ($this->declaredQueue) {
         $this->channel->queue_bind($this->queueConfig['name'], $this->exchangeConfig['name'], $this->queueConfig['routingKey']);
     }
     $this->persistentDelivery = $this->exchangeConfig['durable'] || $this->queueConfig['durable'];
 }