-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 이벤트 발행 과정에서 예외 발생 시 이벤트 발행되지 않도록 수정 (#675)
* test: 동시 참여 시 중복 참여 가능한 상황 테스트 * refactor: 공모 상태 업데이트 로직 이동 * refactor: 사용하지 않는 쿼리 제거 * feat: Offering 테이블 비관적 쓰기 락을 통해 중복 참여 방지 * test: 같은 공모 다른 사용자의 동시 참여 경우 테스트 * refactor: 비관적 쓰기 락 -> 낙관적 락을 통해 중복 참여 방지 * refactor: version 필드 추가로 인한 soft delete 쿼리 수정 * refactor: offeringMember 저장 시 offering의 실 저장 데이터 활용하도록 * refactor: 낙관적 락 -> 비관적 쓰기 락 * refactor: 호출 메서드 트랜잭션 롤백될 경우 발행된 이벤트 처리되지 않도록 * style: 다른 메서드와 변수 선언 순서 통일 * test: 동시 실행 코드 ConcurrencyExecutor 클래스로 추출
- Loading branch information
Showing
4 changed files
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
backend/src/test/java/com/zzang/chongdae/event/service/TestEventPublisher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.zzang.chongdae.event.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationEvent; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
public class TestEventPublisher { | ||
|
||
@Autowired | ||
ApplicationEventPublisher eventPublisher; | ||
|
||
public void publishWithoutTransaction(ApplicationEvent event) { | ||
eventPublisher.publishEvent(event); | ||
} | ||
|
||
@Transactional | ||
public void publishWithTransaction(ApplicationEvent event) { | ||
eventPublisher.publishEvent(event); | ||
} | ||
|
||
@Transactional | ||
public void publishWithTransactionThenThrowException(ApplicationEvent event) { | ||
eventPublisher.publishEvent(event); | ||
throw new RuntimeException(); | ||
} | ||
} |