laravel check code run in queue code example
Example 1: how to automatically run queue in laravel
for queues with no queue name i.e. queue name = default
php artisan queue:work
or
php artisan queue:listen
for jobs with a queue name. Let's assume i have a queue with name = sendemail
php artisan queue:listen --queue=sendemail
note:
queue:work will only work for jobs entries currently in jobs table in database and stop.
queue:listen will go on processing queues continously, both for current and new entries.
Example 2: laravel run a specific queue by name
Execute Laravel queues by queue names on coomand line interface->
// I was using running command
'php artisan queue:work'
// which was not running my queued jobs in jobs table.
// Then i relaized, it was only working for jobs with queue column value = 'default'
// and i had given names like sendemail, inboxemail etc.
// So when i changed this other value to 'default' in queue column in jobs table,
// this job ran instantly as i have opended cli and php artisan queue:work
// command was active.
//So if you want to run only a specific queue by queue name, run command ->
php artisan queue:listen --queue=sendemail
// or
php artisan queue:listen --queue=inboxemail