/**
  * {@inheritdoc}
  */
 public function tick(Queue $queue, array $options = [])
 {
     // weired, no clue why this is necessary, but somehow configure is not invoked otherwise
     $this->doConfigure($options);
     if ($this->controller->doStop()) {
         return false;
     }
     if ($this->controller->doPause()) {
         return true;
     }
     return parent::tick($queue, $options);
 }
 /**
  * {@inheritdoc}
  */
 public function doPause()
 {
     if ($this->fallbackController != null) {
         return $this->fallbackController->doPause();
     }
     pcntl_signal_dispatch();
     return $this->pause;
 }
Esempio n. 3
0
 protected function tick(BackendInterface $backend, array $options = [])
 {
     $this->configure($options);
     $iterator = $backend->getIterator();
     foreach ($iterator as $message) {
         if ($this->controller->doPause()) {
             return true;
         }
         if ($this->controller->doStop()) {
             return false;
         }
         if (microtime(true) > $this->options['max-runtime']) {
             return false;
         }
         $backend->handle($message, $this->notificationDispatcher);
         $this->eventDispatcher->dispatch(IterateEvent::EVENT_NAME, new IterateEvent($iterator, $backend, $message));
         if (null !== $this->options['max-messages'] && !(bool) --$this->options['max-messages']) {
             return false;
         }
     }
     return !$this->options['stop-when-empty'];
 }