3

I have below code in supervisor which keep polling the jobs table

program:laravel-queue-listener]
command=php /var/www/laravel/artisan queue:work --sleep=120 --tries=2 --daemon

Question: Right now, it goes to database to check pending jobs after each 2 minutes...Is there any way to process queues on demand? I meant when the below code executes...it may process the queue and before that check if the queue is already processing or not...

Is there any such function in the Framework to process queues manually and check if the queue is currently polling or processing any job or not?

$User->notify(new RegisterNotification($token, $User));
Pankaj
  • 9,749
  • 32
  • 139
  • 283

1 Answers1

0

I understand your question as how to process queues on demand in Laravel. There is already a detailed answer here but the command you are looking for is.

php artisan queue:work --once

However if what you are trying to do is to run the queue worker when an event happens, you can still do that by invoking the queue worker from code. Example:

public static function boot(){
    static creating($user){
        Artisan::call('queue:work --once');
    }
}
Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65