0

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.

2
  • Can you share how you are dispatching your job? Commented Aug 29, 2019 at 14:07
  • XYJob::dispatch()->onQueue('custom-queue') Commented Aug 30, 2019 at 7:42

2 Answers 2

0

Laravel 5.8 application should has QUEUE_CONNECTION in the .env file.

Sign up to request clarification or add additional context in comments.

Comments

-1

How are you dispatching the job? Have you followed the example on the Laravel doscs site at https://laravel.com/docs/5.8/queues#dispatching-jobs i.e.

\App\Jobs\ProcessPodcast::dispatch($podcast);

or dispatch(new \App\Jobs\ProcessPodcast($podcast);

dispatch(new \App\Jobs\ProcessPodcast($podcast);

If the job is not dispatched in this manner (i.e. you're simply newing up the job class), it will not be pushed to the queue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.