/** * Tests get queue method. */ public function testGetQueue() { $queueAliasResolver = new QueueAliasResolver($this->queues); $this->assertEquals($queueAliasResolver->getQueue('myqueue1'), $this->queues['myqueue1']); $this->assertEquals($queueAliasResolver->getQueue('myqueue2'), $this->queues['myqueue2']); $this->assertEquals($queueAliasResolver->getQueue('myqueue3'), 'myqueue3'); }
/** * 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; }