laravel - QUEUE_CONNECTION 'database' 工作但 'redis' 抛出 'Array to String conversion'

标签 laravel laravel-5 redis laravel-queue laravel-horizon

我只是想运行一个 Event & Listener 循环并将模型传递给它

event(new LabelsCreated($model, 'string'));

这与 QUEUE_CONNECTION=database 完美配合,但与 QUEUE_CONNECTION=redis 配合使用时,它会抛出错误:

#message: "Array to string conversion"

#code: 0

#file: "/home/vagrant/Code/Upworks/myproj/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php"

#line: 302

#severity: E_NOTICE

我的事件类如下所示:

class LabelsCreated
{
    use Dispatchable, SerializesModels;

    public $model;

    public $string;

    public function __construct($model, $string)
    {
        $this->model = $model;
        $this->string = $string;

        // comes here
    }
}

但它根本不会对我的监听器进行排队。


我的config/queue.php,redis数组是这样的:

'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => ['default', 'export'],
        'retry_after' => 90,
        'block_for' => null,
 ],

它可能指的是键“队列”值吗?

最佳答案

这是我的 config/queue.php 中的问题

'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => ['default', 'export'], // THIS LINE
        'retry_after' => 90,
        'block_for' => null,
 ],

我试着保持默认

'queue' => 'default'

它在同一连接上运行多个队列。

深入洞察:https://laracasts.com/discuss/channels/laravel/multiple-queues-for-redis-connection?page=0#reply=461404

关于laravel - QUEUE_CONNECTION 'database' 工作但 'redis' 抛出 'Array to String conversion',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57758755/

相关文章:

php - 两列 where 子句用逗号合并

html - 如何使右侧边栏悬停在页面上下文上而不是占用单独的空间

node.js - 跨环境/dist/index.js :42 unexpected token }

php - 在 Laravel 中删除数据透视表中的行

python - 如何使用 redis-py 在 python 脚本中模拟 redis MONITOR 命令?

php - 使用 PHP 从 Redis 中选择特定模式的所有关键数据

php - Linux计划任务在Laravel中不起作用

php - 从 Laravel 中的 mysql 表中检索值

laravel - Laravel 中的三向多对多关系

redis - Redis 中的键值对是如何存储的?