Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 地平线上的拉威尔队列_Laravel_Queue_Horizon - Fatal编程技术网

Laravel 地平线上的拉威尔队列

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())->

我只需要在队列中添加一个作业。如果队列中有工作者,则下一个作业必须取消。 我的代码: 在Kernel.php中

$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();
在调度程序中-它对我有效