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'];
 }
Beispiel #3
0
 /**
  * Declare AMQP Queue
  * @param string $queue
  * @param bool|false $passive
  * @param bool|false $durable
  * @param bool|false $exclusive
  * @param bool|true $auto_delete
  * @param bool|false $nowait
  * @param null $arguments
  * @param null $ticket
  * @return mixed
  */
 public function queueDeclare($queue = '', $passive = false, $durable = false, $exclusive = false, $auto_delete = true, $nowait = false, $arguments = null, $ticket = null)
 {
     return $this->channel->queue_declare($queue, $passive, $durable, $exclusive, $auto_delete, $nowait, $arguments, $ticket);
 }