Ejemplo n.º 1
0
 /**
  * @return void
  */
 public function initialize()
 {
     if ($this->initialized) {
         return;
     }
     $this->initialized = true;
     $this->exchange->initialize();
     $this->queue->initialize();
     $this->channel->queue_bind($this->queue->name(), $this->exchange->name());
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function consume()
 {
     $this->queue->initialize();
     $service = $this->service;
     $this->channel->basic_consume($this->queue->name(), $this->tag, $this->noLocal, $this->noAck, $this->exclusive, $this->noWait, function (AMQPMessage $message) use($service) {
         $ack = $service->execute($message);
         if ($ack === null || $ack === true) {
             $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
         }
     });
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }