-1

Im trying to send a job to the queue.

Controller

public function play($id, Request $request)
    {

        
        ProcessResult::dispatch($id);
        
        dd ('done');

Job

public function handle()
    {
        sleep(25) {

Code works is fine, but:

  1. 'jobs' table is empty;
  2. page in browser is busy until job is not completed;
  3. dd('done') is not arrived until job is not completed;

Driver is database on localhost. Laravel 9.

What could be a mistake or a general misunderstanding of the logic of the queues?

Shoshin
  • 23
  • 5
  • 1
    It seems your jobs uses `sync` driver, check your env variable. Try to clear your config cache. `php artisan config:clear` – xuma Jun 23 '22 at 13:11
  • Yes, you're right! I changed to 'database' driver in queue.php ('default' => en('QUEUE_CONNECTION', 'database'),). True, of course in .env. Thank you very much! – Shoshin Jun 23 '22 at 15:56

1 Answers1

0

Your problem is that your job is not queued. There are a few things that you must set up in order this to work the way you want. First of all, you must do the following in your job file

use Illuminate\Contracts\Queue\ShouldQueue;

class SomeName implements ShouldQueue {
     //....
}

After that you must install supervisor and set up some things. You can find more information for how to keep laravel queue running in this thread

How to keep Laravel Queue system running on server

Laralex
  • 125
  • 8