예제 #1
0
파일: PubSub.php 프로젝트: so-php/pubsub
 protected function initAmqp()
 {
     if (!$this->declared) {
         $ed = $this->getExchangeDescriptor();
         $ch = $this->getChannel();
         $ed->declareExchange($ch);
         $qd = new QueueDescriptor();
         $qd->setAutoDelete(true);
         $this->setQueueDescriptor($qd);
         $qd->declareQueue($ch);
         $ch->queue_bind($qd->getName(), $ed->getName());
         $cd = new ConsumerDescriptor(array($this, 'onMessage'), $qd->getName());
         $cd->setNoAck(true);
         $cd->consume($ch);
     }
 }
예제 #2
0
파일: Server.php 프로젝트: so-php/rpc
 protected function initAmqp()
 {
     if ($this->getQueueDescriptor() !== null) {
         return;
     }
     $this->setQueueDescriptor(new QueueDescriptor());
     $this->getQueueDescriptor()->declareQueue($this->getChannel());
     $this->setEndpoint(new EndpointDescriptor(null, $this->getQueueDescriptor()->getName()));
     /*
     $this->getChannel()->queue_bind($this->getQueueDescriptor()->getName(),
                                     $this->getEndpoint()->getExchange(),
                                     $this->getEndpoint()->getRoute());
     */
     $cd = new ConsumerDescriptor(array($this, 'processMessage'));
     $cd->setTag($this->getTag());
     $cd->setQueueName($this->getQueueDescriptor()->getName());
     $cd->setTicket($this->getQueueDescriptor()->getTicket());
     $cd->consume($this->getChannel());
 }