在我的项目中使用IronMQ在 Laravel 5.1 中实现队列和作业,我现在可以将作业发送到 IronMQ 队列,如下图所示:
我现在想要的是在我的工作的句柄函数中获取队列中的当前消息数量(红色框中的数字),找到下面的工作代码:
class GetWords extends Job implements SelfHandling, ShouldQueue{
use InteractsWithQueue, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct(Url $url)
{
}
/**
* Execute the job.
*/
public function handle()
{
//getting the name of queue
dd($this->job->getName()); //return 'words'
$currentNumberMsgsInQueue = ?????; //i can't find how
//Condition
if($currentNumberMsgsInQueue == 10){
//Do something
}
}
}
问题是:如何使用 Laravel 在 IronMQ 队列中获取排队作业(消息)的数量?