Conversation
- 2-1 naive @eventlistener fires on rollback; AFTER_COMMIT cancels it - 2-2 phase matrix; after-group order not guaranteed (shared afterCompletion) - 2-4 fallbackExecution=false silently drops listener outside a tx - 2-5 AFTER_COMMIT insert survived w/o REQUIRES_NEW via autoCommit-restore commit on H2 — non-portable, JPA would lose it; REQUIRES_NEW required
cl-o-lc
marked this pull request as ready for review
June 10, 2026 17:02
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이번 주차
진행 상황
환경
MeasurementLog자동 누적(measurements.md)시도한 거 (시간순)
s1 — publishEvent 기초
return이 리스너 뒤에 출력@Order— 숫자 작을수록 먼저(C→B→A로 검증)ApplicationListener<E>vs@EventListener— 같은 메커니즘ApplicationEvent상속 없이 String/record 발행s2 — @TransactionalEventListener 4 phase
6. 2-1: 순진한
@EventListener→ 롤백돼도 알림 이미 전송(함정) →AFTER_COMMIT로 해결7. 2-2: 4 phase를 한 이벤트에 다 붙여 commit/rollback 매트릭스 관찰
8. 2-3: phase 배치 설계 (영수증/포인트/보상/감사) — 결정 기준 도출
9. 2-4: 트랜잭션 밖 publishEvent →
fallbackExecutionfalse/true 비교10. 2-5: BEFORE_COMMIT 영수증(같은 트랜잭션) + AFTER_COMMIT 포인트(REQUIRES_NEW 함정)
s3 — @async
11. 3-1/2: 동기 리스너 vs
@Asyncpublisher 블록 시간 측정12. 3-3: self-invocation —
this.asyncMethod()는@Async무시(5주차 회수)13. 3-6:
@Async+AFTER_COMMIT새 스레드 → 트랜잭션 컨텍스트 유무14. 3-4/5/7: 풀 함정 / 예외 소멸 / Virtual Thread (3-7 실측)
s4 — AOP vs Event
15. 5주차 AuthAspect(게이트+감사) 분해 → AOP/Event 결정 매트릭스
측정 결과
s1 — 동작 관찰 (기대 vs 실제)
s2 — phase 동작
AFTER_COMPLETION이AFTER_COMMIT보다 먼저 출력(셋 다 같은afterCompletion(status)콜백)
fallbackExecution=false조용히 무시 /true즉시 인라인 실행commit(비이식성)
s3 — @async
isVirtual()=true인데 이름은task-1그대로통증 / 막힌 곳
@SpringBootApplication여러 개 → 스캔 섞임. stage별 이벤트 타입 다르게 + flat 구조로 해결ApplicationListener<E>는E extends ApplicationEvent제약 → payload record는 컴파일 에러this호출이 프록시 우회 →@Async무시. 5주차@Transactional함정과 동일@Async+AFTER_COMMIT은 새 스레드라TransactionSynchronizationManager(ThreadLocal) 손실 → DB/영속성 만지면 REQUIRES_NEW 필수해결 후 인사이트
@EventListener)는 내부에서PayloadApplicationEvent<T>로 래핑 → 그래서 인터페이스로 받으려면ApplicationListener<PayloadApplicationEvent<...>>필요하면 Transactional Outbox + MQ로 at-least-once(+멱등)
commit"으로 해결
X라 이벤트로 못 잡음(→ 게이트·감사 모두 AOP)
회고
@DomainEvents/ 영속성 컨텍스트(3-6 LazyInit 예고)로 자연 연결