Php 如果在队列作业运行时未在条件中找到数据,如何再次添加相同的队列作业?

Php 如果在队列作业运行时未在条件中找到数据,如何再次添加相同的队列作业?,php,laravel,Php,Laravel,我想在同一作业运行时添加另一个相同的队列作业。如果作业在不满足条件的情况下运行,则我需要在其中添加另一个队列,并延迟5分钟。有可能吗 让我们使用trait的release函数: 如果要创建新作业实例。也许这会奏效: class ExampleJob implements ShouldQueue { use InteractsWithQueue; public function handle() { // some code. if (!

我想在同一作业运行时添加另一个相同的队列作业。如果作业在不满足条件的情况下运行,则我需要在其中添加另一个队列,并延迟5分钟。有可能吗

让我们使用trait的release函数:

如果要创建新作业实例。也许这会奏效:

class ExampleJob implements ShouldQueue
{
    use InteractsWithQueue;

    public function handle()
    {
        // some code.

        if (! $someCondition) {
            dispatch($this);
            // And return if you want to terminate this job.
            return;
        }         
    }
}

谢谢你的回答@kevin but$this->release();不再为同一操作将另一行添加到jobs表中。我已相应地更新了我的答案,我希望它能起作用。谢谢@kevin$this->dispatch()在我的情况下起作用。
class ExampleJob implements ShouldQueue
{
    use InteractsWithQueue;

    public function handle()
    {
        // some code.

        if (! $someCondition) {
            dispatch($this);
            // And return if you want to terminate this job.
            return;
        }         
    }
}