简体   繁体   中英

When I use laravel5.8's redis queue function, it does not work properly

The larave version is 5.8. I am going to use the queue function of redis. According to the documentation, when I start the queue: work command, it cannot be successfully executed. The error log has an abnormal error

env:

  • 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 monitor redis 监视器

queue work

php artisan queue:work --queue=sso

在此处输入图像描述

error log错误日志

The cause of the error is that the project introduced the php-enqueue / laravel-queue package. The 0.9 version of this package has a bug that was fixed after the upgrade

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM