LaravelCollective / bus

Laravel Command Bus
MIT License
31 stars 10 forks source link

Error when run queue:work #9

Closed ermenagildo closed 6 years ago

ermenagildo commented 8 years ago

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';
}

} `

aranna00 commented 8 years ago

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

Vinlock commented 8 years ago

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 :cry:

GrahamCampbell commented 8 years ago

This package won't work on Laravel 5.3.

GrahamCampbell commented 8 years ago

D'no if it works on the latest 5.2 either.