protected function execute(InputInterface $input, OutputInterface $output)
{
/**
* Define all channels this command must listen to
*/
$this->define();
$serializer = $this->getContainer()->get('rs_queue.serializer');
$resolver = $this->getContainer()->get('rs_queue.resolver.queuealias');
$eventDispatcher = $this->getContainer()->get('event_dispatcher');
$methods = $this->methods;
$channelAliases = array_keys($methods);
$channels = $resolver->getQueues($channelAliases);
if ($this->shuffleQueues()) {
shuffle($channels);
}
$this->getContainer()->get('rs_queue.redis')->subscribe($channels, function ($redis, $channel, $payloadSerialized) use($methods, $resolver, $serializer, $eventDispatcher, $input, $output) {
$channelAlias = $resolver->getQueueAlias($channel);
$method = $methods[$channelAlias];
$payload = $serializer->revert($payloadSerialized);
/**
* Dispatching subscriber event...
*/
$subscriberEvent = new RSQueueSubscriberEvent($payload, $payloadSerialized, $channelAlias, $channel, $redis);
$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);
});
}