示例#1
0
文件: Worker.php 项目: equip/queue
 /**
  * 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;
 }
示例#2
0
文件: EventTest.php 项目: equip/queue
 public function testDrained()
 {
     $this->emitter->expects($this->once())->method('emit')->with(Event::QUEUE_DRAINED);
     $this->event->drained();
 }