/** * @inheritdoc */ public function createQueue(ChannelInterface $channel, $name = null, $flags = null, array $args = []) { $delegate = new \AMQPQueue($channel->getDelegate()); $delegate->setFlags(Queue::convertToDelegateFlags($flags)); $delegate->setArguments($args); if (null !== $name) { $delegate->setName($name); } return new Queue($delegate, $channel); }
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); }
/** * @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; }
/** * Get queue * * @param string $name The queue name * * @return \AMQPQueue */ protected function getQueue($name) { if (isset($this->queues[$name])) { return $this->queues[$name]; } $config = $this->getConfig('queue', $name); if (null === $config) { throw new \InvalidArgumentException("Queue definition '{$name}' doesn't exists."); } $connection = $this->getConnection($config['connection']); $this->queues[$name] = $queue = new \AMQPQueue($connection['channel']); $queue->setFlags(Helper\Options::toFlags($config)); $queue->setName(is_callable($config['name']) ? call_user_func($config['name']) : $config['name']); $queue->declareQueue(); if (isset($config['bindings'])) { foreach ($config['bindings'] as $binding) { try { $this->getExchange($binding['exchange']); } catch (\InvalidArgumentException $e) { } $exchangeConfig = $this->getConfig('exchange', $binding['exchange']); $queue->bind($exchangeConfig['name'], $binding['routing_key'], isset($binding['arguments']) ? $binding['arguments'] : []); } } if (!empty($config['arguments'])) { if (isset($config['arguments']['x-dead-letter-exchange'])) { try { $this->getExchange($config['arguments']['x-dead-letter-exchange']); } catch (\InvalidArgumentException $e) { } } $queue->setArguments($config['arguments']); } return $queue; }
/** * @inheritdoc */ public function setArguments(array $arguments) { $this->queue->setArguments($arguments); }
/** * @inheritdoc */ public function setArguments(array $arguments) { return $this->delegate->setArguments($arguments); }
/** * @param array $arguments * * @return bool */ public function setArguments(array $arguments) { return $this->rawQueue->setArguments($arguments); }