【问题标题】:QUEUE_CONNECTION 'database' works but 'redis' throws 'Array to String conversion'QUEUE_CONNECTION 'database' 有效,但 'redis' 抛出 'Array to String conversion'
【发布时间】:2019-09-02 14:34:29
【问题描述】:

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

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

这与QUEUE_CONNECTION=database 完美配合,但与QUEUE_CONNECTION=redis 配合使用,会引发错误:

#message: "数组到字符串的转换"

#code: 0

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

#line: 302

#severity: E_NOTICE

我的 Event 类如下所示:

class LabelsCreated
{
    use Dispatchable, SerializesModels;

    public $model;

    public $string;

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

        // comes here
    }
}

但它根本没有让我的 Listener 排队。


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

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

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

【问题讨论】:

  • 你从哪里得到$transaction
  • 在我的问题中尝试更通用时是一个错字。这只是一个模型。修正错字

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


【解决方案1】:

这是我的 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-30
    • 2022-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-22
    • 2012-06-09
    • 1970-01-01
    相关资源
    最近更新 更多