oQueueJob = new QueueJob(); } public function fire(Job $job, $data) { $this->oQueueJob->init($job); $expertId = intval(isset($data['expert_id']) ? $data['expert_id'] : 0); $affiliation = isset($data['affiliation']) ? trim((string)$data['affiliation']) : ''; $queue = isset($data['queue']) ? (string)$data['queue'] : 'FetchExperts'; $chatUrl = isset($data['chat_url']) ? (string)$data['chat_url'] : ''; $service = new ExpertFinderService(); try { if ($expertId && $affiliation !== '') { $service->fillExpertCountry($expertId, $affiliation, $chatUrl); } $job->delete(); // 链式:处理完当前专家立刻拉下一个进来 $service->enqueueNextCountryFill(1, $queue, $chatUrl); } catch (\Exception $e) { $this->oQueueJob->handleException($e, $job, "expert_id={$expertId} queue={$queue}"); } catch (\Throwable $e) { $this->oQueueJob->handleException($e, $job, "expert_id={$expertId} queue={$queue}"); } finally { $this->oQueueJob->finnal(); } } }