Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would prevent jobs in a queue from processing? [PHP / Laravel 5]

I have a queue I set up in Laravel 5 to delete companies and associated records. Each time this happens, a lot of work happens on the back-end, so queues are my best option.

I set up my config/queue.php file along with my .env file so that the database driver will be used. I am using the Queue::pushOn method to push jobs onto a queue called company_deletions. Ex.

Queue::pushOn('company_deletions', new CompanyDelete($id));

Where CompanyDelete is a command created with php artisan command:make CompanyDelete --queued

I have tried to get my queue to process using the following commands:

php artisan queue:work
php artisan queue:work company_deletions
php artisan queue:listen
php artisan queue:listen company_deletions
php artisan queue:work database
php artisan queue:listen database

Sometimes when looking at the output of the above commands, I get the following error:

[InvalidArgumentException]  
No connector for []  

Even when I don't get an error I cannot get it to actually process the jobs for some reason. When I look in my jobs table, I can see the job on the queue, however the attempts column shows 0, reserved shows 0 and reserved_at is null. Am I missing some steps? I have looked over the documentation several times and cannot for the life of me figure out what is wrong. I don't see anything in the laravel error logs either. What would prevent these jobs from being processed once they are in the jobs database? Any help is appreciated.

like image 718
DuckPuncher Avatar asked Dec 09 '15 16:12

DuckPuncher


People also ask

How do I know if my Laravel queue is working?

Show activity on this post. This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.

How does queue work in Laravel?

Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time.

What is the difference between job and queue in Laravel?

Jobs and QueuesThe line itself is the Queue, and each customer in the line is a Job. In order to process Jobs in the Queue you need command line processes or daemons. Think of launching a queue daemon on the command line as adding a new bank teller to the pool of available bank tellers.

Why do we use jobs and queue?

Now, if you go back to the jobs table in your database, you’ll find it empty since all the jobs where processed. After we saw how we can dispatch jobs and process them asynchronously (IE: we don’t need to wait for the job to finish), let’s move to the second reason we use jobs and queues: parallelism.

What is the use of queue in Laravel?

Lists are used by Laravel as the data structure to store the jobs, new jobs are pushed to the tail of the queue with RPUSH and the worker process will fetch jobs to process from the head of the queue with LPOP, thereby maintaining the FIFO structure for a queue. The job which gets into the queue first will be processed first.

Why do queue workers restart after deployment?

queue workers are long-lived processes and store the booted application state in memory. As a result, they will not notice changes in your codebase after they have been started. So, during your deployment process, be sure to restart your queue workers. So we need to restart that process again.

What is dispatching to a particular queue?

Dispatching To A Particular Queue By pushing jobs to different queues, you may "categorize" your queued jobs and even prioritize how many workers you assign to various queues. Keep in mind, this does not push jobs to different queue "connections" as defined by your queue configuration file, but only to specific queues within a single connection.


1 Answers

i run into a smiliar issue because i dont add the jobs in the default queue..

        $job = (new EmailJob(
            $this->a,
            $this->b,
            $this->c,
            $this->d,
            $e
        ))->onQueue('emails');

then i have to listen to the specific queue:

php artisan queue:listen --queue=emails

in your case it would be

php artisan queue:listen --queue=company_deletions
like image 61
Alex Meyer Avatar answered Nov 15 '22 00:11

Alex Meyer