How to delete an existing queue task in laravel

不言
Release: 2023-03-01 06:24:01
Original
5574 people have browsed it

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;
}
Copy after login

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

InteractsWithQueue

public function setJob(JobContract $job)
{
    $this->job = $job;
    return $this;
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template