执行队列监听报错

[2017-03-02 19:42:22] local.ERROR: InvalidArgumentException: No handler registered for command [__PHP_Incomplete_Class] in G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php:340
Stack trace:
#0 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(305): Illuminate\Bus\Dispatcher->inflectSegment(Object(__PHP_Incomplete_Class), 0)
#1 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(290): Illuminate\Bus\Dispatcher->getHandlerClass(Object(__PHP_Incomplete_Class))
#2 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(196): Illuminate\Bus\Dispatcher->resolveHandler(Object(__PHP_Incomplete_Class))
#3 [internal function]: Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(__PHP_Incomplete_Class))
#4 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(139): call_user_func(Object(Closure), Object(__PHP_Incomplete_Class))
#5 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(__PHP_Incomplete_Class))
#6 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): call_user_func(Object(Closure), Object(__PHP_Incomplete_Class))
#7 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(205): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#8 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(43): Illuminate\Bus\Dispatcher->dispatchNow(Object(__PHP_Incomplete_Class), Object(Closure))
#9 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(130): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#10 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Jobs\RedisJob.php(50): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#11 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(208): Illuminate\Queue\Jobs\RedisJob->fire()
#12 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(158): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), '0', '0')
#13 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(108): Illuminate\Queue\Worker->pop(NULL, 'default', '0', '3', '0')
#14 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(70): Illuminate\Queue\Console\WorkCommand->runWorker(NULL, 'default', '0', '128', false)
#15 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#16 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Container\Container.php(502): call_user_func_array(Array, Array)
#17 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Console\Command.php(150): Illuminate\Container\Container->call(Array)
#18 G:\rrd\mch\vendor\symfony\console\Command\Command.php(259): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Console\Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 G:\rrd\mch\vendor\symfony\console\Application.php(878): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 G:\rrd\mch\vendor\symfony\console\Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 G:\rrd\mch\vendor\symfony\console\Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 G:\rrd\mch\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(100): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 G:\rrd\mch\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 {main}

修改队列配置文件config/queue.php中的队列名称

'redis' => [
    'driver' => 'redis',
    'connection' => 'default',
    'queue'  => 'default',//default改为其它名字如default02
    'expire' => 60,
],

google到的参考地址

https://github.com/laravel/framework/issues/13222


queue配置文件解析

 'default' => env('QUEUE_DRIVER', 'sync'),

    /*
    |--------------------------------------------------------------------------
    | Queue Connections
    |--------------------------------------------------------------------------
    |
    | Here you may configure the connection information for each server that
    | is used by your application. A default configuration has been added
    | for each back-end shipped with Laravel. You are free to add more.
    |
    */

    'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'database' => [
            'driver' => 'database',
            'table' => 'jobs',
            'queue' => 'default',
            'expire' => 60,
        ],

        'beanstalkd' => [
            'driver' => 'beanstalkd',
            'host'   => 'localhost',
            'queue'  => 'default',
            'ttr'    => 60,
        ],

        'sqs' => [
            'driver' => 'sqs',
            'key'    => 'your-public-key',
            'secret' => 'your-secret-key',
            'queue'  => 'your-queue-url',
            'region' => 'us-east-1',
        ],

        'iron' => [
            'driver'  => 'iron',
            'host'    => 'mq-aws-us-east-1.iron.io',
            'token'   => 'your-token',
            'project' => 'your-project-id',
            'queue'   => 'your-queue-name',
            'encrypt' => true,
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue'  => 'default',
            'expire' => 60,
        ],

    ],

该配置文件第一个配置项default用于指定默认的队列驱动,这里我们将其值改为redis(实际上是修改.env中的QUEUE_DRIVER)。

connections配置项包含了Laravel支持的所有队列驱动,我们使用Redis驱动,所以需要配置redis项:

connection对应config/database.php中redis的default配置;

queue为默认队列名称,上面修改了该名称;

expire为队列任务过期时间(秒)。

这里我们可以保持其默认配置不变。


failed配置项用于配置失败队列任务存放的数据库及数据表。这里我们需要按照自己的数据库配置对其做相应修改。