24 lines
575 B
PHP
24 lines
575 B
PHP
|
<?php
|
|||
|
|
|||
|
namespace app\job;
|
|||
|
|
|||
|
use app\common\logic\task\TaskLogic;
|
|||
|
use think\queue\Job;
|
|||
|
|
|||
|
/**
|
|||
|
* 任务下发执行的具体逻辑
|
|||
|
*/
|
|||
|
class TaskAdd
|
|||
|
{
|
|||
|
|
|||
|
public function fire(Job $job, $data)
|
|||
|
{
|
|||
|
if ($job->attempts() > 3) {
|
|||
|
//通过这个方法可以检查这个任务已经重试了几次了
|
|||
|
}
|
|||
|
TaskLogic::CronAdd($data['data'],$data['data_two']);
|
|||
|
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
|||
|
$job->delete();
|
|||
|
}
|
|||
|
}
|