Home  >  Article  >  Backend Development  >  How to delete an existing queue task in laravel

How to delete an existing queue task in laravel

不言
不言Original
2018-05-15 11:28:495551browse

Added a scheduled task to the queue. For some reasons, there is no need to execute this task.

So how to delete the specified task from the queue?

Reply content:

Added a scheduled task to the queue . For some reasons, there is no need to perform this task.
So how do you delete the specified task from the queue?

The complete process is complicated and lengthy, so I will just focus on it, basically adding Queue A series of processing will be carried out, and this section will be executed:

CallQueuedHandler

protected function setJobInstanceIfNecessary(Job $job, $instance)
{
    // class_uses_recursive 可以取得類所使用到的 trait
    if (in_array('Illuminate\Queue\InteractsWithQueue', class_uses_recursive(get_class($instance)))) {
        // 所以假如類有 use Illuminate\Queue\InteractsWithQueue
        // 就呼叫 setJob($job)
        $instance->setJob($job);
    }
    return $instance;
}

And setJob is the method of InteractsWithQueue, which is a simple assignment

InteractsWithQueue

public function setJob(JobContract $job)
{
    $this->job = $job;
    return $this;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn