首页 > 解决方案 > Yii2 队列信息显示所有参数为 0,但获取作业

问题描述

我有一个关于 Yii2 队列工作的问题。这是我在组件 api/config/web.php 中的配置部分

'redisNotificationsQueue' => [
            'class' => \yii\queue\redis\Queue::class,
            'as log' => \yii\queue\LogBehavior::class, //The default error log is console/runtime/logs/app.log
            'attempts' => 5, // Max number of attempts
            'ttr' => 1020,  // max TTL of process - since API call can take upto 15 minutes extra 2 minutes for the rest of processes
            'channel' => 'notifications', // Queue channel key,
            'on afterError' => function (ExecEvent $event) {
                if ($event->job instanceof SendNotifications) {
                    $event->retry = ($event->attempt < 5) && ($event->error instanceof TemporaryException);
                }
            },
        ]

在模型中,我添加了这样的工作


$id = \Yii::$app->redisNotificationsQueue->push(new SendNotification([
                     'email' => $subscriber->email,
                ]));

之后我得到了 id 但是当我运行这个命令 php yii queue/info 来查看信息台时,我得到了这个

Jobs
- waiting: 0
- delayed: 0
- reserved: 0
- done: 0

我做错了什么?

标签: phpyii2queue

解决方案


推荐阅读