浏览代码

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

workジョブでシングルトンになっていたため2重のトランザクションが発生していた
master
sosuke.iwabuchi 1年前
父节点
当前提交
5cbd28776c
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. +4
    -5
      app/Jobs/BaseJob.php

+ 4
- 5
app/Jobs/BaseJob.php 查看文件

@@ -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;
}
}


正在加载...
取消
保存