From f5451b433226d4102d94145c7ff2f79a47cd384f Mon Sep 17 00:00:00 2001 From: "Leoncio, Leo" Date: Mon, 1 Apr 2024 15:24:51 -0400 Subject: [PATCH] + RetryableJobInterface --- src/jobs/EmailJob.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/jobs/EmailJob.php b/src/jobs/EmailJob.php index b278ba3..d41ddc7 100644 --- a/src/jobs/EmailJob.php +++ b/src/jobs/EmailJob.php @@ -11,8 +11,9 @@ use craft\queue\BaseJob; use leowebguy\simplelogger\SimpleLogger; +use yii\queue\RetryableJobInterface; -class EmailJob extends BaseJob +class EmailJob extends BaseJob implements RetryableJobInterface { public array $to; @@ -21,6 +22,16 @@ public function defaultDescription(): string return 'Sending Simple Logger Report'; } + public function getTtr(): float|int + { + return 15 * 60; + } + + public function canRetry($attempt, $error): bool + { + return ($attempt < 2) && ($error instanceof TemporaryException); + } + public function execute($queue): void { SimpleLogger::getInstance()->loggerService->sendMail($this->to);