Add retries when job execute failed
This commit is contained in:
@ -59,6 +59,8 @@ class Queue extends Ideal\Service
|
|||||||
try {
|
try {
|
||||||
if (!$worker->execute($job)) {
|
if (!$worker->execute($job)) {
|
||||||
$this->logger->debug("Could not execute job {$job->id}");
|
$this->logger->debug("Could not execute job {$job->id}");
|
||||||
|
$job->retries++;
|
||||||
|
$this->jobService->update($job);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$this->jobService->execute($job)) {
|
if (!$this->jobService->execute($job)) {
|
||||||
@ -67,6 +69,12 @@ class Queue extends Ideal\Service
|
|||||||
}
|
}
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
$this->logger->warning("Could not run job {$job->id}", ['exception' => $exception]);
|
$this->logger->warning("Could not run job {$job->id}", ['exception' => $exception]);
|
||||||
|
$job->retries++;
|
||||||
|
try {
|
||||||
|
$this->jobService->update($job);
|
||||||
|
} catch (Update $exception) {
|
||||||
|
$this->logger->error($exception->getMessage(), ['job' => $job, 'exception' => $exception]);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user