Laravel队列:不允许“关闭”的作业序列化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Laravel队列:不允许“关闭”的作业序列化相关的知识,希望对你有一定的参考价值。
我已经尝试过this和this的决心,最后,他们没有解决我的问题。
我把这份工作添加到我的队列中
public function successPayment(Request $request){
$command = Command::findOrFail($request->reference);
if($command->state == Command::PENDING){
$command->state = Command::SUCCESS;
$command->payed_at = now();
if(!empty($oldCommandItem = session('renew_command')))
{
$commandItem = $command->items()->offers()->get()->first();
$commandItem->application_id = $oldCommandItem->application->id;
$commandItem->save();
$notification = $user->notifications->last();
$application = $commandItem->application;
RestoreApplicationJob::dispatch(['application'=>$application, 'notification'=>$notification]);
$next = route('application.show', $commandItem->application_id);
session()->forget('renew_command');
}
$command->save();
}
}
而我的工作
class RestoreApplicationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $datas;
public $tries = 1;
public function __construct($datas)
{
$this->datas = $datas;
}
public function handle()
{
try{
$application = $this->datas['application'];
$notification = $this->datas['notification'];
$application->activate();
$tmp_data = $notification->data;
$tmp_data['state'] = Opertation::SUCCESS;
$notification->data = $tmp_data;
$notification->save();
}catch(Exception $e)
{
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$tmp_data = $notification->data;
$tmp_data['state'] = Opertation::FAILED;
$notification->data = $tmp_data;
$notification->save();
}
}
}
我有这个错误:
不允许序列化'Closure'
我多次检查它卡住的地方但没有找到任何东西
谢谢你的帮助,对不起我这么糟糕的英语:)!
答案
我的问题太疯狂了......
我只是在Job中调用类qazxsw poi而不是qazxsw poi。抛出异常......
以上是关于Laravel队列:不允许“关闭”的作业序列化的主要内容,如果未能解决你的问题,请参考以下文章