本文介绍了未定义的属性:Illuminate \ Queue \ Jobs \ BeanstalkdJob :: $ name的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将 beanstalkd 与 Laravel 一起使用来对一些任务进行排队,但是我无法将数据发送到处理队列的功能,这是我的代码
I'm using beanstalkd with Laravel to queue some tasks but I'm having trouble to send data to the function that handles the queue , Here is my code
//Where I call the function
$object_st = new stdClass();
$object_st->Person_id = 2 ;
//If I do this: echo($object_st->Person_id); , I get 2
Queue::push('My_Queue_Class@My_Queue_Function', $object_st );
处理队列的函数如下
public function My_Queue_Function( $Data )
{
$Person_id = $Data->Person_id; //This generate the error
//Other code
}
错误提示:
推荐答案
4.2中队列的工作方式不同于5;处理队列任务的函数中的第一个参数实际上是队列作业实例,第二个参数将是您的数据:
The way queues work in 4.2 is different than 5; the first argument in the function that handles the queue task is actually a queue job instance, the second argument would be your data:
class SendEmail {
public function fire($job, $data)
{
//
}
}
根据文档中的示例.
您的代码因此需要允许第一个参数:
Your code would therefor need to allow the first argument:
public function My_Queue_Function( $job, $Data )
{
$Person_id = $Data['Person_id'];
//Other code
}
这篇关于未定义的属性:Illuminate \ Queue \ Jobs \ BeanstalkdJob :: $ name的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!