Based on Mohamed Said's video shorts series on queues: https://themsaid.com/explaining-laravel-queue-configuration-keys
- The
queue.redis.retry_after
attribute is for when you don't hear back from a job (it didn't succeed and it didn't fail for N seconds), consider it as failed and retry it again.- This is different from when you set the
$retryAfter
public property or aretryAfter()
method on the job class. Here it means if the job fails, retry it after N seconds.- This is equal to the
--delay
flag on thequeue:work
command itself. -
--delay
in your console command is different than setting the$delay
public property on the job itself. The$delay
public property here means each time this job is pushed to the queue, delay processing it for N seconds.
- This is equal to the
- This is different from when you set the
- When you set the
$timeout
public property on the job class, you're saying if the job is processing for more than N seconds, kill the worker process and stop processing the job and let it retry again.- This is the same as setting the
--timeout
argument in thequeue:work
console command.- You should set the
queue.redis.retry_after
configuration option to be more than the$timeout
of the job itself or the worker.
- You should set the
-
$timeout
is different than$timeoutAt
.$timeoutAt
means if the job fails, keep retrying it until the set time.- You can do the same using the
retryUntil()
method.
- You can do the same using the
- So even if you have
$tries
set and the job fails, the worker will ignore that value and keep retrying the job until the$timeoutAt
time regardless of the number of attempts.
- This is the same as setting the
- The
queue.redis.block_for
configuration says when you open a connection to redis and you can't find any jobs, wait for N seconds at the redis level before sleeping and starting a new loop to check for new jobs again. - The
queue.redis.queue
configuration tells redis which queues to process jobs form first. So ifqueue.redis.queue = high,low
then redis will not process jobs from thelow
queue in until thehigh
queue is empty. - Setting the
--stop-when-empty
flag on thequeue:work
command will terminate the worker when there aren't any jobs in the queue left to process. Note: A service like supervisor will restart the process over and over.-
--stop-when-empty
is useful for example in a Docker container. Start the container when the queue is filled with jobs and the container will process all the jobs in the queue, and when it's finished it will be terminated.
-
Hope this helps.
2,141
views