Laravel 地平线上的拉威尔队列
我只需要在队列中添加一个作业。如果队列中有工作者,则下一个作业必须取消。 我的代码: 在Kernel.php中Laravel 地平线上的拉威尔队列,laravel,queue,horizon,Laravel,Queue,Horizon,我只需要在队列中添加一个作业。如果队列中有工作者,则下一个作业必须取消。 我的代码: 在Kernel.php中 $schedule->command('source')->withoutOverlapping()->everyMinute(); 指挥 $count = Redis::lrange('queues:source', 0, -1); if (count($count) == 0) dispatch((new \App\Jobs\Source())->
$schedule->command('source')->withoutOverlapping()->everyMinute();
指挥
$count = Redis::lrange('queues:source', 0, -1);
if (count($count) == 0)
dispatch((new \App\Jobs\Source())->onConnection('redis')->onQueue('source'));
在职
public function handle()
{
dump('job work');
sleep(2000);
}
但我看到了未来的工作机会。如何解决这个问题
$schedule
->call(function () {
if (Queue::size('source') == 0)
dispatch(new TestJob())->onQueue('source');
})
->everyMinute();
在调度程序中-它对我有效