If you notice your jobs run more than once, make sure the retry_after
configuration of the queue connection has a larger value than the job/worker timeout
. For example:
'redis' => [
'retry_after' => 90,
],
If your job takes more than 90 seconds to run, another worker could pick it up while it's still running. Make sure the timeout
value is shorter so the job fails before it gets picked up again:
php artisan queue:work --timeout=60
Same for the job-specific timeout:
class MyJob implements ShouldQueue
{
public $timeout = 70;
}
If you use SQS, the retry_after
is identified by the queue's Visibility Timeout.