Error when run queue:work
Closed this issue · 4 comments
After running --queue=test from DB have error:
InvalidArgumentException: No handler registered for command [App\Jobs\TestJob]
PS:
Collective\Bus\BusServiceProvider::class, // added to config/app.php
PSS:
Laravel Framework version 5.2.29
`<?php
namespace App\Jobs;
use App\Jobs\Job;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class TestJob extends Job implements ShouldQueue {
use InteractsWithQueue, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct() {
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle() {
echo 'test';
}
}
`
Did you upgrade from laravel 5.1 to 5.2?
if you did remove:
Collective\Bus\BusServiceProvider::class
and add
Illuminate\Bus\BusServiceProvider::class,
I had the same problem, so I decided to create a new project and copy parts back and forth until things worked.
after 3 hours of looking at the differences between all the files I found that this was added in the new version but couldn't find it in the old.
The queue started working after I copied that into the main config
I did not upgrade from 5.1 to 5.2, though it still seems that I am getting this error as well on v5.2.45.
I do have Illuminate\Bus\BusServiceProvider::class,
in my app.php
file.
InvalidArgumentException \vendor\laravelcollective\bus\src\Dispatcher.php:348
No handler registered for command [App\Jobs\TestJob]
I have attempted to call the job in multiple different ways.
$queue = Queue::later(\Carbon\Carbon::now()->addMinutes(1), (new \App\Jobs\TestJob(\Carbon\Carbon::now())));
$job = (new \App\Jobs\TestJob(\Carbon\Carbon::now()))->delay(10);
$queue = dispatch($job);
All attempts result in the same exception and fail.
[2016-08-29 09:22:22] Failed: App\Jobs\TestJob
Please help 😢
This package won't work on Laravel 5.3.
D'no if it works on the latest 5.2 either.