Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 public function testAdd()
 {
     $command = new Command();
     $queue = 'test-queue';
     $this->driver->expects($this->once())->method('enqueue')->with($queue, $command)->willReturn(true);
     $this->assertTrue($this->queue->add($queue, $command));
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function execute($command, callable $next)
 {
     if ($command instanceof QueueableCommand) {
         $queue = $this->getQueue(get_class($command));
         return $this->queue->add($queue, new QueuedCommand($command));
     }
     if ($command instanceof QueuedCommand) {
         $command = $command->command();
     }
     return $next($command);
 }