Example #1
0
 public function it_should_initialize(\AMQPQueue $queue, Exchange $exchange, Context $context)
 {
     $exchange->getName()->willReturn('exchange');
     $context->getFlags()->willReturn(1234);
     $context->getArguments()->willReturn(['foo' => 'bar']);
     $queue->setName('queue')->shouldBeCalled();
     $queue->bind('exchange')->shouldBeCalled();
     $queue->setFlags(1234)->shouldBeCalled();
     $queue->setArguments(['foo' => 'bar'])->shouldBeCalled();
     $queue->declareQueue()->shouldBeCalled();
     $this->initialize($queue);
     $this->isInitialized()->shouldReturn(true);
 }
Example #2
0
 /**
  * @param \AMQPQueue|null $queue
  *
  * @throws HectorException
  */
 public function initialize(\AMQPQueue $queue = null)
 {
     if (true === $this->isInitialized()) {
         throw new HectorException('Queue already initialized');
     }
     if (null === $queue) {
         $queue = new \AMQPQueue($this->channel->getWrappedChannel());
     }
     $this->queue = $queue;
     $this->queue->setName($this->getName());
     $this->queue->bind($this->exchange->getName());
     $this->queue->setFlags($this->context->getFlags());
     $this->queue->setArguments($this->context->getArguments());
     $this->queue->declareQueue();
     $this->initialized = true;
 }