/** * Handles fetching messages from the queue * * @param string $queue * * @return bool */ protected function tick($queue) { if ($this->shutdown) { $this->event->shutdown(); return false; } list($command, $job) = $this->driver->dequeue($queue); if (empty($command) && $this->drain) { $this->event->drained(); return false; } elseif (empty($command)) { return true; } try { $this->event->acknowledge($command); $this->command_bus->handle($command); $this->event->finish($command); } catch (Exception $exception) { $this->queue->add(sprintf('%s-failed', $queue), $command); $this->event->reject($command, $exception); } finally { $this->driver->processed($job); } return true; }
public function testDrained() { $this->emitter->expects($this->once())->method('emit')->with(Event::QUEUE_DRAINED); $this->event->drained(); }