在我的项目中使用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队列中排队作业(消息)的数量?