aiService = app(AiTranslateService::class); return $this->aiService->processTranslate($this->messageId, $messageData, $this); } catch (\Exception $e) { // 记录失败指标 throw $e; } finally { // 记录处理时间 $processingTime = microtime(true) - $startTime; Log::info('翻译处理耗时', ['time' => $processingTime]); } } protected function handleFinalFailure(array $messageData, \Exception $exception) { parent::handleFinalFailure($messageData, $exception); // 消息处理最终失败,准备发送到死信队列 $this->aiService->handleFailedTranslate($this->messageId, $messageData, $exception); } }