我正在做一个需要实时广播纬度和经度的项目
我有类似下面的东西
namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Support\Facades\Redis;
class TrackersBroadcast extends Event implements ShouldBroadcast
{
public $lat, $lng,$imei,$date_time
use SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(
$lat,
$lng,
$imei,
$date_time
)
{
$this->lat = $lat;
$this->lng = $lng;
$this->imei = $imei;
$this->date_time = $date_time;
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return ['tracker-channel'];
}
}
在某些情况下我需要触发实时电子邮件,所以我决定实现如下的 laravel 消息队列
namespace App\Jobs;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Mail;
class SendAlertEmail extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
public $data;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($data)
{
$this->data=$data;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
Mail::send('emails.test', ['testVar' => $this->data], function($message) {
$message->from('no-reply@sample.com', 'Website Name');
$message->to('developer@gmail.com')->subject('A simple test');
});
}
}
每当我运行php artisan queue:listen database
它时,它也会将我的广播事件排队。我不想排队广播事件。怎么做?