jeudi 29 août 2019

How to push the Laravel job to the queue

I have a class XYJob which was created by artisan command and implements the ShouldQueue class. The QUEUE_DRIVER=redis in the .env file.

The problem is that when i dispatch the job, it runs as a simple php function. The queue listener is not running, but the job runs as a simple function.

It is laravel 5.8 application with predis/predis: ^1.1. I have tried to clear the cache and the config. I have tried to use composer dump-autoload.

namespace Modules\ModuleName\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class XYJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        \Log::info('Job is running');
    }
}

Laravel documentation says:

The generated class will implement the ShouldQueue interface, indicating to Laravel that the job should be pushed onto the queue to run asynchronously.

BUT my job is definitely running.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HyjJmY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire