Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute laravel job (queue)?

developers, I have a problem. My queue not working or i just not understand how it's works. I create a command which should add a new queue job. Driver for Queue is - database. After executing my command i see a new row in table 'jobs'. After that I try to do "php artisan queue:work" - but nothing happens.

Help me please, how can I execute this job?

like image 430
lieroes Avatar asked May 06 '16 08:05

lieroes


People also ask

What is job queue in Laravel?

Laravel queues provide a unified queueing API across a variety of different queue backends, such as Amazon SQS, Redis, or even a relational database. Laravel's queue configuration options are stored in your application's config/queue.php configuration file.

How do I know if Laravel queue is running?

$this->mailer->queue($view, $data, function ($message) use ($toEmail, $toName, $subject) { $message ->to($toEmail, $toName) ->subject($subject); }); This will successfully run, but if the queue is not 'listening', the job gets pushed on to the job table, forever.

What is a queue job?

A job queue contains an ordered list of jobs waiting to be processed by a subsystem. The job queue is the first place that a submitted batch job goes before becoming active in a subsystem. The job is held here until a number of factors are met.


1 Answers

From the documentation : [Daemon Queue Listener] The queue:work artisan command includes a --daemon option for forcing the queue worker to continue processing jobs without ever re-booting the framework. This results in a significant reduction of CPU usage when compared to the queue:listen command:

To start a queue worker in daemon mode, use the --daemon flag:

php artisan queue:work connection --daemon

However if you don't have multiple connections remove connection and execute it without connection :

php artisan queue:work --daemon

It worked for me.

like image 134
Himanshu Bhandari Avatar answered Sep 17 '22 15:09

Himanshu Bhandari