添加 implements ShouldQueue,修改为 Redis 后队列一直 fail ,为什么?(去掉之后,修改为 sync 同步是好使的)

添加 implements ShouldQueue,修改 QUEUE_DRIVER 为 redis 后队列一直 fail

去掉 implements ShouldQueue 之后,修改 QUEUE_DRIVER 为 sync 同步是好使的

file

App\Notifications\TopicReplied
ID
341
Queue
default
Tags
Failed At
18-08-17 10:42:18
Error
ErrorException: Undefined property: App\Notifications\TopicReplied::$reply in /home/vagrant/datas/wwwroot/larabbs/app/Notifications/TopicReplied.php:64
Stack trace:
#0 /home/vagrant/datas/wwwroot/larabbs/app/Notifications/TopicReplied.php(64): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined prope...', '/home/vagrant/d...', 64, Array)
#1 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(50): App\Notifications\TopicReplied->toMail(Object(App\Models\User))
#2 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(113): Illuminate\Notifications\Channels\MailChannel->send(Object(App\Models\User), Object(App\Notifications\TopicReplied))
#3 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(89): Illuminate\Notifications\NotificationSender->sendToNotifiable(Object(App\Models\User), '6377e113-903c-4...', Object(App\Notifications\TopicReplied), 'mail')
#4 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(50): Illuminate\Notifications\NotificationSender->sendNow(Object(Illuminate\Database\Eloquent\Collection), Object(App\Notifications\TopicReplied), Array)
#5 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php(57): Illuminate\Notifications\ChannelManager->sendNow(Object(App\Models\User), Object(App\Notifications\TopicReplied), Array)
#6 [internal function]: Illuminate\Notifications\SendQueuedNotifications->handle(Object(Illuminate\Notifications\ChannelManager))
#7 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#8 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#9 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#10 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#11 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#12 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#13 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))
#14 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#15 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Notifications\SendQueuedNotifications), false)
#16 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(76): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#17 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(320): Illuminate\Queue\Jobs\Job->fire()
#18 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(270): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#19 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(114): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#20 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#21 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#22 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#23 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#24 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#25 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#26 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#27 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#28 /home/vagrant/datas/wwwroot/larabbs/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#29 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#30 /home/vagrant/datas/wwwroot/larabbs/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /home/vagrant/datas/wwwroot/larabbs/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Horizon\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /home/vagrant/datas/wwwroot/larabbs/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /home/vagrant/datas/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /home/vagrant/datas/wwwroot/larabbs/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 {main}
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 4
老好人

仔细检查一下你的app/Notifications/TopicReplied.php文件,要么是没有引入(use App\Models\Reply),要么是没有定义public $reply,要么是__construct()没有初始化reply属性。

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\Models\Reply;

class TopicReplied extends Notification implements ShouldQueue
{
    use Queueable;

    public $reply;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Reply $reply)
    {
        //注入回复实体,方便toDatabase方法中的使用
        $this->reply = $reply;
    }
7个月前
heibai_2018

碰到了跟你一模一样的问题了,不用队列发可以受到邮件,换用redis队列,跟你一样的错误

5个月前

ErrorException: Undefined property: App\Notifications\TopicReplied::$reply in /home/vagrant/datas/wwwroot/larabbs/app/Notifications/TopicReplied.php:64
错误提示这么明显啊,不仔细看看么?

4个月前

@老好人 虽然你的答案是对的,我忘记定义 public $reply;了, 但你的答案出来的排版太乱了,我第一次竟然没有看到,最后还是自己来查找的问题解决的,还是感谢了。

4个月前

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!