mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
Improve Scheduler task with try-catch-finally. Jobs should be deleted from db on error to prevent looping. Also errors should be logged
This commit is contained in:
parent
b3b516d0ad
commit
c834816e19
@ -15,6 +15,7 @@ use DateTimeImmutable;
|
|||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Xentral\Components\Database\Database;
|
use Xentral\Components\Database\Database;
|
||||||
|
use Xentral\Components\Logger\Logger;
|
||||||
use Xentral\Modules\SubscriptionCycle\Service\SubscriptionCycleJobService;
|
use Xentral\Modules\SubscriptionCycle\Service\SubscriptionCycleJobService;
|
||||||
use Xentral\Modules\SubscriptionCycle\SubscriptionCycleModuleInterface;
|
use Xentral\Modules\SubscriptionCycle\SubscriptionCycleModuleInterface;
|
||||||
use Xentral\Modules\SubscriptionCycle\SubscriptionModuleInterface;
|
use Xentral\Modules\SubscriptionCycle\SubscriptionModuleInterface;
|
||||||
@ -58,15 +59,23 @@ final class SubscriptionCycleManualJobTask
|
|||||||
$this->taskMutexService->setMutex('rechnungslauf_manual');
|
$this->taskMutexService->setMutex('rechnungslauf_manual');
|
||||||
$jobs = $this->cycleJobService->listAll(100);
|
$jobs = $this->cycleJobService->listAll(100);
|
||||||
foreach ($jobs as $job) {
|
foreach ($jobs as $job) {
|
||||||
switch ($job['document_type']) {
|
try {
|
||||||
case 'rechnung':
|
switch ($job['document_type']) {
|
||||||
$this->subscriptionModule->CreateInvoice((int)$job['address_id']);
|
case 'rechnung':
|
||||||
break;
|
$this->subscriptionModule->CreateInvoice((int)$job['address_id']);
|
||||||
case 'auftrag':
|
break;
|
||||||
$this->subscriptionModule->CreateOrder((int)$job['address_id']);
|
case 'auftrag':
|
||||||
break;
|
$this->subscriptionModule->CreateOrder((int)$job['address_id']);
|
||||||
}
|
break;
|
||||||
$this->cycleJobService->delete((int)$job['id']);
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
/** @var Logger $logger */
|
||||||
|
$logger = $this->app->Container->get('Logger');
|
||||||
|
$logger->error($e->getMessage(), $job);
|
||||||
|
} finally {
|
||||||
|
$this->cycleJobService->delete((int)$job['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user