cqp 1 zi în urmă
părinte
comite
9997d025c2
1 a modificat fișierele cu 18 adăugiri și 0 ștergeri
  1. 18 0
      app/Jobs/ProcessDataJob.php

+ 18 - 0
app/Jobs/ProcessDataJob.php

@@ -10,6 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 use MongoDB\Driver\Exception\Exception;
 use Symfony\Component\Console\Output\ConsoleOutput;
@@ -72,6 +73,23 @@ class ProcessDataJob implements ShouldQueue
         ]);
     }
 
+    public function failed(\Throwable $exception)
+    {
+        Log::error('ProcessDataJob 失败', [
+            'error' => $exception->getMessage(),
+            'data' => $this->data,
+        ]);
+
+        // 保底清理
+        try {
+            $service = new \App\Service\TPlusServerService();
+            $service->delTableKey($this->type);
+        } catch (\Throwable $e) {
+            Log::warning('清理 Redis Key 失败:' . $e->getMessage());
+        }
+    }
+
+
     protected function echoMessage(OutputInterface $output)
     {
         //输出消息