I have a Laravel with some Jobs that are usually very quick to run. Hence I have configured my default retry_after in config/queue.php to 20 seconds
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 20,
],
I do however have one type of Jobs that can take much longer, up to a few minutes, so I have upgraded to Laravel 5.8 to be able to specify a retry-after parameter specific to this class:
class LongJob implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout = 600;
public $tries = 3;
public $retryAfter = 610;
However, when I dispatch a LongJob to the queue, I find in my logs that the job is called twice, i.e., at dispatch, and then 20 seconds after.
Can you think of any reason why Laravel would not "see" my $retryAfter option - which from what I understand is supposed to override the global setting?
EDIT: after further testing, it seems that $retryAfter and retry_after do not work exactly the same... From what I've tried:
- a job will be attempted again after
retry_after
seconds, regardless of whether it's still running from a previous attempt - when a job fails and is released back into the queue, it will attempted again after
$retryAfter
seconds
Hence in my case, correct values would be:
retry_after = 610; //As long as the longest timeout is + small buffer
$retryAfter = 5; //I'd like my job to be re-attempted quickly after it fails
Not sure if a bug or a feature...