Parcourir la source

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

workジョブでシングルトンになっていたため2重のトランザクションが発生していた
master
sosuke.iwabuchi il y a 1 an
Parent
révision
5cbd28776c
1 fichiers modifiés avec 4 ajouts et 5 suppressions
  1. +4
    -5
      app/Jobs/BaseJob.php

+ 4
- 5
app/Jobs/BaseJob.php Voir le fichier

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

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

protected DBUtil $db;

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

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

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


Chargement…
Annuler
Enregistrer