예제 #1
0
 /**
  * Execute code.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     /*
      * Define all channels this command must listen to
      */
     $this->define();
     $channelAliases = array_keys($this->methods);
     $channels = $this->queueAliasResolver->getQueues($channelAliases);
     if ($this->shuffleQueues()) {
         shuffle($channels);
     }
     $this->redis->subscribe($channels, function ($redis, $channel, $payloadSerialized) use($input, $output) {
         $channelAlias = $this->queueAliasResolver->getQueue($channel);
         $method = $this->methods[$channelAlias];
         $payload = $this->serializer->revert($payloadSerialized);
         /*
          * Dispatching subscriber event...
          */
         $subscriberEvent = new RSQueueSubscriberEvent($payload, $payloadSerialized, $channelAlias, $channel, $redis);
         $this->eventDispatcher->dispatch(RSQueueEvents::RSQUEUE_SUBSCRIBER, $subscriberEvent);
         /*
          * All custom methods must have these parameters
          *
          * InputInterface  $input   An InputInterface instance
          * OutputInterface $output  An OutputInterface instance
          * Mixed           $payload Payload
          */
         $this->{$method}($input, $output, $payload);
     });
     return 0;
 }
예제 #2
0
 /**
  * Tests get queue method.
  */
 public function testGetQueues()
 {
     $queueAliasResolver = new QueueAliasResolver($this->queues);
     $this->assertEquals($queueAliasResolver->getQueues(array_keys($this->queues)), array_values($this->queues));
 }