Esempio n. 1
0
 /**
  * Open a connection with the RabbitMQ Server
  *
  * @return void
  */
 public function open()
 {
     try {
         $this->AMQPConnection = new AMQPConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
         $this->channel = $this->AMQPConnection->channel();
         $this->channel->queue_declare($this->queue_name, false, true, false, false);
         $this->channel->exchange_declare($this->queue_name, 'x-delayed-message', false, true, false, false, false, new AMQPTable(["x-delayed-type" => "direct"]));
         $this->channel->queue_bind($this->queue_name, $this->queue_name);
     } catch (Exception $e) {
         throw new Exception($e);
     }
 }
Esempio n. 2
0
 /**
  * Open a connection with the RabbitMQ Server
  *
  * @return void
  */
 public function open()
 {
     try {
         $this->AMQPConnection = new AMQPConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
         $this->channel = $this->AMQPConnection->channel();
         $this->channel->queue_declare($this->queue_name, false, true, false, false);
         $this->channel->exchange_declare($this->exchange, 'direct', false, true, false);
         $this->channel->queue_bind($this->queue_name, $this->exchange);
     } catch (Exception $e) {
         throw new Exception($e);
     }
 }
 /**
  * create queue.
  *
  * @param string $name
  * @param int    $timeout
  *
  * @return bool
  */
 public function create($name, $timeout = null)
 {
     try {
         /*
             name: $queue
             passive: false
             durable: true // the queue will survive server restarts
             exclusive: false // the queue can be accessed in other channels
             auto_delete: false //the queue won't be deleted once the channel is closed.
         */
         $this->channel->queue_declare($name, false, true, false, false);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }