Example #1
1
 /**
  * @inheritdoc
  */
 public function addJobToQueue(Queue $queue, Job &$job)
 {
     $qb = $this->connection->createQueryBuilder();
     $qb->insert($this->getQueueTableName())->values([$this->columns['__CLASS__'] => ':class', $this->columns[JobReflector::PROPERTY_QUEUE] => ':queue', $this->columns[JobReflector::PROPERTY_CREATED] => ':created', $this->columns[JobReflector::PROPERTY_SCHEDULE] => ':schedule', $this->columns[JobReflector::PROPERTY_FAILED] => ':failed', $this->columns[JobReflector::PROPERTY_FINISHED] => ':finished', $this->columns[JobReflector::PROPERTY_RESULT] => ':result', $this->columns[JobReflector::PROPERTY_PROGRESS] => ':progress', $this->columns[JobReflector::PROPERTY_LAST_ATTEMPT] => ':lastAttempt', $this->columns[JobReflector::PROPERTY_TIMEOUT] => ':timeout', $this->columns[JobReflector::PROPERTY_RETRY_COUNT] => ':retryCount', $this->columns[JobReflector::PROPERTY_RETRY] => ':retry', $this->columns[JobReflector::PROPERTY_VERSION] => ':version', $this->columns[JobReflector::PROPERTY_PARAMETERS] => ':parameters'])->setParameters(['class' => get_class($job), 'queue' => $queue->getName(), 'created' => (new DateTimeImmutable())->format('Y-m-d H:i:s'), 'schedule' => JobReflector::getSchedule($job) ? JobReflector::getSchedule($job)->format('Y-m-d H:i:s') : (new DateTimeImmutable())->format('Y-m-d H:i:s'), 'failed' => false, 'finished' => null, 'result' => null, 'progress' => null, 'lastAttempt' => null, 'timeout' => null, 'retryCount' => 0, 'retry' => false, 'version' => JobReflector::getVersion($job), 'parameters' => json_encode(JobReflector::getParameters($job))]);
     $qb->execute();
     return $this->connection->lastInsertId('job_seq');
 }
Example #2
0
 /**
  * Get the key for the given queue.
  *
  * @param Queue $queue
  *
  * @return string
  */
 private function getKeyForQueue(Queue $queue)
 {
     return $this->getQueueKeyPrefix() . $queue->getName();
 }