Serialization of 'Closure' is not allowed

WilliamQian發表於2020-06-12

我監聽了佇列任務失敗事件,失敗後,傳送一條通知到郵箱

  1. 這是通知類的程式碼
    有人知道這是什麼問題嗎?

  2. 這是監聽失敗任務的程式碼

有人知道這是什麼問題嗎?

  1. 我如果不傳event給通知類,能正常執行,但是傳了event,就不能執行,報下面的錯誤
    [2020-06-12 16:07:59] local.ERROR: Serialization of 'Closure' is not allowed {"exception":"[object] (Exception(code: 0): Serialization of 'Closure' is not allowed at E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php:140)
    [stacktrace]
    #0 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(140): serialize(Object(Illuminate\\Notifications\\SendQueuedNotifications))
    #1 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(111): Illuminate\\Queue\\Queue->createObjectPayload(Object(Illuminate\\Notifications\\SendQueuedNotifications), 'queues:job_fail...')
    #2 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\RedisQueue.php(153): Illuminate\\Queue\\Queue->createPayloadArray(Object(Illuminate\\Notifications\\SendQueuedNotifications), 'queues:job_fail...', '')
    #3 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(89): Illuminate\\Queue\\RedisQueue->createPayloadArray(Object(Illuminate\\Notifications\\SendQueuedNotifications), 'queues:job_fail...', '')
    #4 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\RedisQueue.php(91): Illuminate\\Queue\\Queue->createPayload(Object(Illuminate\\Notifications\\SendQueuedNotifications), 'queues:job_fail...', '')
    #5 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Queue.php(45): Illuminate\\Queue\\RedisQueue->push(Object(Illuminate\\Notifications\\SendQueuedNotifications), '', 'job_failed_noti...')
    #6 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(177): Illuminate\\Queue\\Queue->pushOn('job_failed_noti...', Object(Illuminate\\Notifications\\SendQueuedNotifications))
    #7 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(160): Illuminate\\Bus\\Dispatcher->pushCommandToQueue(Object(Illuminate\\Queue\\RedisQueue), Object(Illuminate\\Notifications\\SendQueuedNotifications))
    #8 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php(73): Illuminate\\Bus\\Dispatcher->dispatchToQueue(Object(Illuminate\\Notifications\\SendQueuedNotifications))
    #9 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php(201): Illuminate\\Bus\\Dispatcher->dispatch(Object(Illuminate\\Notifications\\SendQueuedNotifications))
    #10 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php(76): Illuminate\\Notifications\\NotificationSender->queueNotification(Array, Object(App\\Notifications\\JobFailed))
    #11 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\ChannelManager.php(39): Illuminate\\Notifications\\NotificationSender->send(Array, Object(App\\Notifications\\JobFailed))
    #12 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\AnonymousNotifiable.php(38): Illuminate\\Notifications\\ChannelManager->send(Object(Illuminate\\Notifications\\AnonymousNotifiable), Object(App\\Notifications\\JobFailed))
    #13 E:\\projects\\phpweb\\test.com\\app\\Providers\\AppServiceProvider.php(54): Illuminate\\Notifications\\AnonymousNotifiable->notify(Object(App\\Notifications\\JobFailed))
    #14 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Events\\Dispatcher.php(374): App\\Providers\\AppServiceProvider->App\\Providers\\{closure}(Object(Illuminate\\Queue\\Events\\JobFailed))
    #15 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Events\\Dispatcher.php(224): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Queu...', Array)
    #16 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Jobs\\Job.php(185): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Queu...')
    #17 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(482): Illuminate\\Queue\\Jobs\\Job->fail(Object(Overtrue\\EasySms\\Exceptions\\NoGatewayAvailableException))
    #18 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(469): Illuminate\\Queue\\Worker->failJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Overtrue\\EasySms\\Exceptions\\NoGatewayAvailableException))
    #19 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(399): Illuminate\\Queue\\Worker->markJobAsFailedIfWillExceedMaxAttempts('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), 1, Object(Overtrue\\EasySms\\Exceptions\\NoGatewayAvailableException))
    #20 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(372): Illuminate\\Queue\\Worker->handleJobException('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions), Object(Overtrue\\EasySms\\Exceptions\\NoGatewayAvailableException))
    #21 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(314): Illuminate\\Queue\\Worker->process('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions))
    #22 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Worker.php(134): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), 'redis', Object(Illuminate\\Queue\\WorkerOptions))
    #23 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon('redis', 'default', Object(Illuminate\\Queue\\WorkerOptions))
    #24 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Console\\WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'default')
    #25 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
    #26 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(32): call_user_func_array(Array, Array)
    #27 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
    #28 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
    #29 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
    #30 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(590): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
    #31 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(134): Illuminate\\Container\\Container->call(Array)
    #32 E:\\projects\\phpweb\\test.com\\vendor\\symfony\\console\\Command\\Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
    #33 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
    #34 E:\\projects\\phpweb\\test.com\\vendor\\symfony\\console\\Application.php(1001): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #35 E:\\projects\\phpweb\\test.com\\vendor\\symfony\\console\\Application.php(271): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #36 E:\\projects\\phpweb\\test.com\\vendor\\symfony\\console\\Application.php(147): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #37 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #38 E:\\projects\\phpweb\\test.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(131): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #39 E:\\projects\\phpweb\\test.com\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
    #40 {main}
    "} 
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章