Skip to content

Commit cfe5ceb

Browse files
committed
Merge branch 'master' of https://github.com/coolseven/notes
merge remote changes
2 parents a913582 + 6022fa8 commit cfe5ceb

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

thinkphp-queue/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ namespace application\index\controller;
201201
* @param array|mixed $data 发布任务时自定义的数据
202202
*/
203203
public function fire(Job $job,$data){
204-
204+
         // 如有必要,可以根据业务需求和数据库中的最新数据,判断该任务是否仍有必要执行.
205+
         $isJobStillNeedToBeDone = $this->checkDatabaseToSeeIfJobNeedToBeDone($data);
206+
         if(!isJobStillNeedToBeDone){
207+
$job->delete();
208+
return;
209+
}
210+
       
205211
$isJobDone = $this->doHelloJob($data);
206212

207213
if ($isJobDone) {
@@ -219,6 +225,15 @@ namespace application\index\controller;
219225
}
220226
}
221227
}
228+
229+
/**
230+
      * 有些消息在到达消费者时,可能已经不再需要执行了
231+
* @param array|mixed $data 发布任务时自定义的数据
232+
* @return boolean 任务执行的结果
233+
      */
234+
     private function checkDatabaseToSeeIfJobNeedToBeDone($data){
235+
return true;
236+
}
222237

223238
/**
224239
* 根据消息中的数据进行实际的业务处理

0 commit comments

Comments
 (0)