Selaa lähdekoodia

JOBのトランザクションを修正

workジョブでシングルトンになっていたため2重のトランザクションが発生していた
master
sosuke.iwabuchi 1 vuosi sitten
vanhempi
commit
5cbd28776c
1 muutettua tiedostoa jossa 4 lisäystä ja 5 poistoa
  1. +4
    -5
      app/Jobs/BaseJob.php

+ 4
- 5
app/Jobs/BaseJob.php Näytä tiedosto

@@ -8,26 +8,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;


abstract class BaseJob implements ShouldQueue abstract class BaseJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


protected DBUtil $db;


public function handle() public function handle()
{ {
$this->db = DBUtil::instance();
try { try {
$this->db->beginTransaction();
DB::beginTransaction();


$this->logConfig(); $this->logConfig();
$this->handleJob(); $this->handleJob();


$this->db->commit();
DB::commit();
} catch (Exception $e) { } catch (Exception $e) {
$this->db->rollBack();
DB::rollBack();
throw $e; throw $e;
} }
} }


Loading…
Peruuta
Tallenna