Reputation: 7895
I'm getting a bit confused with laravel --queue
option and reserved
column (using mysql).
1- as laravel documentation has stated :
php artisan queue:listen --queue=high,low
In this example, jobs on the high queue will always be processed before moving onto jobs from the low queue.
lets say i have a high
job and multiple low
job. job high
get fired and because of an issue pushed back to queue to fire again after 60 seconds. what happen in this period? does job low
get started or no?
2- Does queue:work --daemon
work just like queue:listen
? I mean does it process all jobs like what listen
do?
3- what is reserved
column for?
Upvotes: 3
Views: 3863
Reputation: 3277
Since there is no accepted answer, and I happened to search and investigate about all of these issues, let me answer them:
jobs from low
will be processed, at least for 60 seconds. After 60 seconds, the job from high
will become available, so it will be processed before of the remaining low
jobs.
At writing time, March 2019, and since version 5:3, the suggested way to use queues is queue:work
, that is the daemonized version of queue:listen
In current version there is a reserved_at
column representing the time in which a job was assigned to a worker to process it.
Upvotes: 2
Reputation: 653
I can only guess here, but I assume high
job would be retried before low
ones. That's why you should use tries=3(or whatever)
flag when running the worker or add public $tries = 5;
to the Job class. Or you could take advantage of InteractsWithQueue
trait for even finer control.
I believe, later Laravel versions run in daemon mode by default when you use queue:work
command. Daemon worker processes are long lived and work faster as they don't need to restart the whole framework for every new job. The queue:listen
command isn't even documented in the latest (5.4) version docs. The worker spawned by this command restarts itself before every job poll. Personally, I still use this, as I've got issues with memory when running daemon workers.
As I understand, this column is the way to mark when the specific job was started to be executed. In the queue.php
config file you can specify when the connection should retry the job. I think the connection decides if the job should be retried by looking at reserved
column.
Upvotes: 2