Esempio n. 1
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;
 }
Esempio n. 2
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;
 }
Esempio n. 3
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);
 }