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); } }
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()); }