You are here

public function Database::retryJob in Advanced Queue 8

Retries the given job.

Parameters

\Drupal\advancedqueue\Job $job: The job.

int $delay: The time, in seconds, after which the retried job will become available to consumers. Defaults to 0, indicating no delay.

Throws

\InvalidArgumentException Thrown if the given job is in an invalid state (not Job::STATE_FAILED).

Overrides BackendInterface::retryJob

File

src/Plugin/AdvancedQueue/Backend/Database.php, line 151

Class

Database
Provides the database queue backend.

Namespace

Drupal\advancedqueue\Plugin\AdvancedQueue\Backend

Code

public function retryJob(Job $job, $delay = 0) {
  if ($job
    ->getState() != Job::STATE_FAILURE) {
    throw new \InvalidArgumentException('Only failed jobs can be retried.');
  }
  $job
    ->setNumRetries($job
    ->getNumRetries() + 1);
  $job
    ->setAvailableTime($this->time
    ->getCurrentTime() + $delay);
  $job
    ->setState(Job::STATE_QUEUED);
  $this
    ->updateJob($job);
}