diff --git a/src/Queue/AWSSQS/SqsQueueManager.php b/src/Queue/AWSSQS/SqsQueueManager.php index 7837903..fdb550e 100644 --- a/src/Queue/AWSSQS/SqsQueueManager.php +++ b/src/Queue/AWSSQS/SqsQueueManager.php @@ -256,11 +256,11 @@ public function pushDelayedWithMilliseconds(JobInterface $job, int $delayInMilli * implementation of automated tests & synthetic monitoring of delayed job * scheduler on live environments while maintaining quick feedback loop. */ - public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDelayInSeconds = self::MAX_DELAY_IN_SECONDS): void + public function pushDelayed(JobInterface $job, int $delayInSeconds, ?int $maxDelayInSeconds = self::MAX_DELAY_IN_SECONDS): void { assert( - $maxDelayInSeconds >= 0, - 'Argument $maxDelayInSeconds must be greater or equal to 0', + $maxDelayInSeconds === null || $maxDelayInSeconds >= 0, + 'If argument $maxDelayInSeconds is specified, it must be greater or equal to 0', ); $prefixedQueueName = $this->getPrefixedQueueName($job->getJobDefinition()->getQueueName()); @@ -272,6 +272,12 @@ public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDela $finalDelayInSeconds = $delayInSeconds; + if ($maxDelayInSeconds === null) { + $this->planExecutionUsingSqsDeliveryDelay($job, $prefixedQueueName, $delayInSeconds, $finalDelayInSeconds); + + return; + } + if ($delayInSeconds > $maxDelayInSeconds) { if ($this->delayedJobScheduler !== null) { $this->scheduleJob($job, $prefixedQueueName, $executionPlannedAt, $delayInSeconds, $maxDelayInSeconds); diff --git a/src/Queue/QueueManagerInterface.php b/src/Queue/QueueManagerInterface.php index 62c6212..6fae042 100644 --- a/src/Queue/QueueManagerInterface.php +++ b/src/Queue/QueueManagerInterface.php @@ -21,7 +21,7 @@ public function push(JobInterface $job): void; * implementation of automated tests & synthetic monitoring of delayed job * scheduler on live environments while maintaining quick feedback loop. */ - public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDelayInSeconds): void; + public function pushDelayed(JobInterface $job, int $delayInSeconds, ?int $maxDelayInSeconds = null): void; public function pushDelayedWithMilliseconds(JobInterface $job, int $delayInMilliseconds): void;