/**
  * @param $command
  * @param callable $next
  * @return string
  */
 public function execute($command, callable $next)
 {
     if ($command instanceof QueuedCommand && !$command->isRunningInQueue()) {
         $queueName = $command->getQueueName();
         $delay = $command->getDelay() !== null ?: $this->delay;
         if (!$queueName) {
             if ($this->defaultQueueName) {
                 $queueName = $this->defaultQueueName;
             } else {
                 $queueName = get_class($command);
             }
         }
         return $this->queue->push(['serializer' => $this->serializer, 'object' => call_user_func($this->serializer[0], $command)], $queueName, $delay);
     }
     return $next($command);
 }
Ejemplo n.º 2
0
 /**
  * @param $job
  */
 protected function delete($job)
 {
     $this->queue->delete(['queue' => $job['queue'], 'body' => Json::encode(['id' => $job['id'], 'body' => $job['body']])]);
     Console::output("Job ID#{$job['id']} was deleted from queue");
 }