| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\job;
- use think\queue\Job;
- use think\facade\Log;
- /**
- * Description of Messenger
- *
- * @author sgq
- */
- class Messenger {
- public function fire(Job $job, $data) {
- if ($this->deal($data)) {
- Log::record(json_encode($data));
- $job->delete();
- return true;
- }
- Log::error(json_encode($data));
- if ($job->attempts() >= 3) {
- $job->delete();
- return false;
- }
- $job->release(10); //10秒后重试
- }
- /**
- * 处理业务逻辑
- * @param type $data
- * @return bool
- */
- public function deal($data): bool {
- $type = $data["type"];
- switch ($data) {
- case 1:
- //通知单位审核注册
- break;
- case 2:
- break;
- }
- return false;
- }
- }
|