public function it_should_create_exchange_from_connection_name(ConnectionRegistry $connectionRegistry, Connection $connection, ChannelFactory $channelFactory, ExchangeRegistry $exchangeRegistry, ExchangeFactory $exchangeFactory, Channel $channel, Exchange $exchange)
 {
     $connectionRegistry->getConnection('default')->willReturn($connection);
     $channelFactory->createFromConnection($connection, Argument::type(Identity::class))->willReturn($channel);
     $exchangeRegistry->hasExchange('exchange', $channel)->willReturn(false);
     $exchangeFactory->createNamed('exchange', $channel)->willReturn($exchange);
     $this->create('default', 'exchange')->shouldReturnAnInstanceOf(Publisher::class);
 }
Beispiel #2
0
 public function it_should_reuse_existing_exchange_when_its_same_channel_and_same_exchange(ConnectionRegistry $connectionRegistry, Connection $connection, ChannelFactory $channelFactory, Channel $channel, Exchange $exchange, Queue $queue, ExchangeRegistry $exchangeRegistry, QueueRegistry $queueRegistry)
 {
     $connectionRegistry->getConnection('default')->willReturn($connection);
     $channelFactory->createFromConnection($connection, Argument::type(Identity::class))->willReturn($channel);
     $exchangeRegistry->hasExchange('exchange', $channel)->willReturn(true);
     $exchangeRegistry->getExchange('exchange', $channel)->willReturn($exchange);
     $queueRegistry->hasQueue('queue', $channel, $exchange)->willReturn(true);
     $queueRegistry->getQueue('queue', $channel, $exchange)->willReturn($queue);
     $consumer = $this->createFromConnection($connection, 'exchange', 'queue');
     $consumer->shouldBeAnInstanceOf(Consumer::class);
 }
Beispiel #3
0
 /**
  * @param Connection $connection
  * @param string     $exchangeName
  * @param array      $options
  *
  * @return Publisher
  */
 public function createFromConnection(Connection $connection, $exchangeName, Channel $channel = null, array $options = [])
 {
     $identity = new Identity();
     if (null === $channel) {
         $channel = $this->channelFactory->createFromConnection($connection, $identity);
     }
     if (!$this->exchangeRegistry->hasExchange($exchangeName, $channel)) {
         $exchange = $this->exchangeFactory->createNamed($exchangeName, $channel);
     } else {
         $exchange = $this->exchangeRegistry->getExchange($exchangeName, $channel);
     }
     $publisher = new Publisher($identity, $this->eventDispatcher, $connection, $channel, $exchange, $options);
     return $publisher;
 }
Beispiel #4
0
 /**
  * @param Connection $connection
  * @param string     $exchangeName
  * @param string     $queueName
  *
  * @return Consumer
  */
 public function createFromConnection(Connection $connection, $exchangeName, $queueName)
 {
     $identity = new Identity();
     $channel = $this->channelFactory->createFromConnection($connection, $identity);
     if (!$this->exchangeRegistry->hasExchange($exchangeName, $channel)) {
         $exchange = $this->exchangeFactory->createNamed($exchangeName, $channel);
     } else {
         $exchange = $this->exchangeRegistry->getExchange($exchangeName, $channel);
     }
     if (!$this->queueRegistry->hasQueue($queueName, $channel, $exchange)) {
         $queue = $this->queueFactory->createNamed($queueName, $channel, $exchange);
     } else {
         $queue = $this->queueRegistry->getQueue($queueName, $channel, $exchange);
     }
     $consumer = new Consumer($identity, $connection, $channel, $exchange, $queue);
     return $consumer;
 }
Beispiel #5
0
 public function it_should_create_exchange(Channel $channel, ExchangeRegistry $exchangeRegistry, ContextRegistry $contextRegistry, Context $context)
 {
     $contextRegistry->getExchangeContext('exchange')->willReturn($context);
     $exchange = $this->createNamed('exchange', $channel);
     $exchangeRegistry->addExchange($exchange)->shouldHaveBeenCalled();
 }
Beispiel #6
0
 /**
  * @param string  $name
  * @param Channel $channel
  *
  * @return Exchange
  */
 public function createNamed($name, Channel $channel)
 {
     $exchange = new Exchange($name, $channel, $this->contextRegistry->getExchangeContext($name));
     $this->exchangeRegistry->addExchange($exchange);
     return $exchange;
 }