Home > Article > Backend Development > How to delete an existing queue task in laravel
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?
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; }