0
votes

I'm trying to set up queues and jobs in a laravel project using the database queue driver and supervisor. When I dispatch a job, I get this error

exception 'InvalidArgumentException' with message 'No handler registered for command [App\Jobs\IndexUser]'

Job:

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

class IndexUser
{
    use InteractsWithQueue, Queueable, SerializesModels;

Dispatch:

dispatch((new IndexUser($this->user->id, $user_status))->onQueue('index_user'));

I think it might be because of this package installed. But I cannot remove it as I am using it vastly.

laravelcollective/html

The PHP version is 5.6 and laravel version is 5.1. Updating these is not an option as it is not in my hands.

Things I tried:

  1. When I use SelfHandling in the Job it works fine but does not use the database as driver nor supervisor which is what I want.

    class IndexUser implements SelfHandling

  2. Installing this package https://github.com/AltThree/Bus/tree/v1.1.0. But composer returns an error because the package requires higher laravel version.

Is there any way to fix this?

1
I think you should be implementing the ShouldQueue interface and possibly extend the App\Jobs\Job classPtrTon
@PtrTon you are right. I was missing the ShouldQueue interface. Works fine now. ThanksSaeesh Tendulkar

1 Answers

0
votes

I was missing the ShouldQueue interface in the job. This fixed it

use Illuminate\Contracts\Queue\ShouldQueue;

class IndexUser extends Job implements SelfHandling, ShouldQueue
{