我正在尝试将Laravel中的作业分派到mysql中。如果我这样做
发送(新发送广播SMS());
或
SendBroadcastSMS::dispatch()->延迟(现在()->添加分钟(2));
这项工作总是在中间进行。在我的作业中,我将睡眠时间设置为30秒,调用dispatch的当前控制器/页面也将等待30秒并回显作业返回。为什么?它应该通过worker在后台运行,对吗?还是我误解了拉拉维尔队?
我的工作如下:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SendBroadcastSMS implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct()
{
}
public function handle()
{
sleep(30);
echo "test";
// dd($this->sendSms("6281517777767","test message"));
//
}
}
我的队列驱动程序是数据库mysql,我也没有在中收到任何行
job
桌子
队列驱动程序=数据库