From f2ecf3a676f0f9af7fb07108d6f7e826998d5054 Mon Sep 17 00:00:00 2001 From: Klaus Date: Sun, 27 Aug 2023 20:10:23 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=A9=EC=A0=84=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EA=B0=80=20=EC=A0=81=EC=9A=A9=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/can/charge/event/ChargeEventService.kt | 3 --- .../sodalive/can/charge/event/ChargeSpringEvent.kt | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeEventService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeEventService.kt index c2b9e04..8ec871a 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeEventService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeEventService.kt @@ -15,8 +15,6 @@ import kr.co.vividnext.sodalive.member.auth.AuthRepository import org.springframework.context.ApplicationEventPublisher import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Propagation -import org.springframework.transaction.annotation.Transactional import kotlin.math.ceil import kotlin.math.round @@ -29,7 +27,6 @@ class ChargeEventService( private val chargeEventRepository: ChargeEventRepository, private val applicationEventPublisher: ApplicationEventPublisher ) { - @Transactional(propagation = Propagation.REQUIRES_NEW) fun applyChargeEvent(chargeId: Long, memberId: Long) { val charge = chargeRepository.findByIdOrNull(chargeId) ?: throw SodaException("이벤트가 적용되지 않았습니다.\n고객센터에 문의해 주세요.") diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeSpringEvent.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeSpringEvent.kt index b0a6d88..2bf349d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeSpringEvent.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/event/ChargeSpringEvent.kt @@ -3,6 +3,9 @@ package kr.co.vividnext.sodalive.can.charge.event import kr.co.vividnext.sodalive.member.Member import org.springframework.scheduling.annotation.Async import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Propagation +import org.springframework.transaction.annotation.Transactional +import org.springframework.transaction.event.TransactionPhase import org.springframework.transaction.event.TransactionalEventListener class ChargeSpringEvent( @@ -15,7 +18,8 @@ class ChargeSpringEventListener( private val chargeEventService: ChargeEventService ) { @Async - @TransactionalEventListener + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + @Transactional(propagation = Propagation.REQUIRES_NEW) fun applyChargeEvent(event: ChargeSpringEvent) { chargeEventService.applyChargeEvent(event.chargeId, event.member.id!!) }