protected function execute(InputInterface $input, OutputInterface $output)
{
$this->define();
$consumer = $this->getContainer()->get('rsqueue.consumer');
$iterations = (int) $input->getOption('iterations');
$timeout = (int) $input->getOption('timeout');
$sleep = (int) $input->getOption('sleep');
$iterationsDone = 0;
$queuesAlias = array_keys($this->methods);
if ($this->shuffleQueues()) {
shuffle($queuesAlias);
}
while ($response = $consumer->consume($queuesAlias, $timeout)) {
list($queueAlias, $payload) = $response;
$method = $this->methods[$queueAlias];
/**
* 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);
if ($iterations > 0 && ++$iterationsDone >= $iterations) {
break;
}
sleep($sleep);
}
}