当我使用laravel5.8的redis队列功能时,它无法正常工作

时间:2020-04-16 08:17:42

标签: php laravel redis

larave版本是5.8。我将使用redis的队列功能。根据文档,当我启动queue:work命令时,它无法成功执行。错误日志中有异常错误

环境:

  • laravel5.8
  • php7.2.21
  • redis5.0.5

config / queue.php

'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => env('REDIS_QUEUE', 'sso'),
            'retry_after' => 90,
            'block_for' => null,
        ],

app / Jobs / LoginLog.php

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;

class LoginLog implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $data;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($appId)
    {
        $this->data = $appId;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::info('job handle...',$this->data);
    }
}

routes / web.php

Route::get('test', function (){
    $appid = '1854956778';
    $a = \App\Jobs\LoginLog::dispatch($appid);
    dd($a);
});

邮递员测试 postman test

redis监控器 redis monitor

排队工作

php artisan queue:work --queue=sso

enter image description here

错误日志 error log

1 个答案:

答案 0 :(得分:0)

错误的原因是该项目引入了php-enqueue / laravel-queue软件包。此软件包的0.9版本具有一个在升级后已修复的错误