Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/#754 delete with outbox #758

Closed
wants to merge 5 commits into from

Conversation

jjongwa
Copy link
Member

@jjongwa jjongwa commented Nov 26, 2023

πŸ“„ Summary

#757 μ—μ„œμ˜ 제 μ˜κ²¬μ— λŒ€ν•œ 좔가적인 μ„€λͺ…을 μœ„ν•œ PRμž…λ‹ˆλ‹€.
νŒ¨ν‚€μ§€ μ˜μ‘΄μ„±μ΄λž‘ flyway script 같은 건 신경쓰지 말고 κ·Έλƒ₯ 이런 식이닀 λŠλ‚Œλ§Œ λ΄μ£Όμ„Έμš”!

757prκ³Ό 같은 역할을 μ΄μ •λ„μ˜ μ½”λ“œ μΆ”κ°€λ‘œ ν•΄κ²°ν•  수 μžˆλ‹€κ³  μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€!
μ™œλƒν•˜λ©΄ μ €ν¬λŠ” 단일 λͺ¨λ“ˆ ꡬ쑰이기 λ•Œλ¬Έ..!
κ·Έλž˜μ„œ μ œκ°€ κ΅¬ν˜„ν•œ ν•΄λ‹Ή 방식이
일반적으둜 κ²€μƒ‰ν•˜λ©΄ λ‚˜μ˜€λŠ” transactional outbox patternκ³ΌλŠ” 쑰금 λ‹€λ₯Ό 수 μžˆμ§€λ§Œ μ˜λ―ΈλŠ” λΉ„μŠ·ν•˜λ‹€κ³  μƒκ°ν•΄μš”.

μ–΄λ– ν•œ νŒ¨ν„΄μ΄λ‚˜ κΈ°λŠ₯을 μ°¨μš©ν•  λ•Œμ—λŠ” ν˜„μž¬ 상황을 νŒŒμ•…ν•˜κ³  그에 맞게 λ³€ν™”λœ λ°©μ‹μœΌλ‘œ μ μš©ν•˜λŠ”κ²Œ κ°€μž₯ μ€‘μš”ν•˜λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€!
κ·Έλž˜μ„œ μ €ν¬μ˜ μ„œλΉ„μŠ€ κ΅¬μ‘°μ—μ„œλŠ” ꡳ이 이벀트 νκΉŒμ§€ μ“Έ ν•„μš”κ°€ μ—†λ‹€κ³  νŒλ‹¨ν–ˆκ΅¬μš”.
μ œκ°€ κ΅¬ν˜„ν•œ λ°©μ‹μ—μ„œ 방지할 수 μ—†λŠ” 문제 상황이 μžˆλ‹€λ©΄ 리뷰 λ‚¨κ²¨μ£Όμ„Έμš”!

πŸ™‹πŸ» More

Copy link

github-actions bot commented Nov 26, 2023

πŸ“ Jacoco Test Coverage

Total Project Coverage 78.12% ❌
File Coverage [81.68%]
DeleteEventListener.java 100% 🍏
TargetType.java 100% 🍏
TripService.java 97.73% 🍏
OutBoxExecutor.java 84.31% 🍏
OutBox.java 80.65% 🍏
LoginService.java 30.49% ❌

@drunkenhw
Copy link

쒋은 생각인 것 κ°™μ•„μš” μ €λŠ” approve ν•˜κ² μŠ΅λ‹ˆλ‹€.

@jjongwa jjongwa force-pushed the refactor/#754-deleteWithOutbox branch from 427e830 to e6c87c1 Compare November 28, 2023 13:24
Copy link
Collaborator

@hgo641 hgo641 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ””λ…Έκ°€ μ›ν•˜λŠ” 방식이 어떀건지 잘 이해가 λ˜μ—ˆμŠ΅λ‹ˆλ‹€! πŸ‘
μ½”λ“œμ˜ˆμ‹œκ°μ‚¬ν•©λ‹ˆλ‹€!

@@ -65,6 +66,7 @@ public void deleteTrip(final TripDeleteEvent event) {

dayLogRepository.deleteByIds(dayLogIds);
tripCityRepository.deleteAllByTripId(event.getTripId());
outBoxRepository.deleteByTargetId(event.getTripId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetIdκ°€ κ²ΉμΉ μˆ˜λ„ μžˆμœΌλ‹ˆ typeμ •λ³΄κΉŒμ§€ ν•¨κ»˜ λ„£μ–΄μ€˜μ•Όκ² κ΅°μš”

private final ApplicationEventPublisher publisher;

@Scheduled(cron = "*/2 * * * * *")
public void execute() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

큐없이 μŠ€μΌ€μ€„λ§μ—μ„œ λ°”λ‘œ λ°œν–‰ν•˜λŠ”κ΅°μš”! ν™•μ‹€νžˆ μ§€κΈˆμ€ μˆœμ„œκ°€ μ€‘μš”ν•œ μ΄λ²€νŠΈκ°€ μ—†μœΌλ‹ˆ λ””λ…Έλ§λŒ€λ‘œ 이 방식이 더 λͺ…λ£Œν•΄λ³΄μž…λ‹ˆλ‹€

Comment on lines +28 to +29
if (outBox.isMember()) {
final List<Long> tripIds = customTripRepository.findTripIdsByMemberId(outBox.getTargetId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outbox에 λͺ¨λ“  정보λ₯Ό μ €μž₯ν•˜λŠ” λŒ€μ‹  νƒ€κ²Ÿ λ„λ©”μΈμ˜ μ•„μ΄λ””λ§Œ μ €μž₯ν•˜κ³ , λ‚˜λ¨Έμ§€ μ •λ³΄λŠ” λ‹€μ‹œ μ‘°νšŒν•΄μ„œ κ°€μ Έμ˜€λŠ”κ΅°μš”!
μ „ ν•„μš”ν•œ 값을 μ „λΆ€ outbox에 μ €μž₯ν•˜λŠ” μˆ˜λ°–μ— μ—†λ‹€κ³  μƒκ°ν–ˆλŠ”λ°, μƒκ°ν•΄λ³΄λ‹ˆ μ΄λ ‡κ²Œ λ‹€μ‹œ 가져와도 λ˜λŠ” κ±°μ˜€λ„€μš”γ…‹γ…‹γ…‹ λ„˜ μ’‹μŠ΅λ‹ˆλ‹€ 무리가 λ˜λŠ” 쿼리도 μ•„λ‹Œ 것 κ°™λ„€μš”!

outbox에 μ§λ ¬ν™”λœ κ°’μœΌλ‘œ 정보 λ‹€ μ €μž₯ν•  λ•Œ, 이거 λ¦¬μŠ€νŠΈλŠ” μ§„μ§œ 콀마둜 κ΅¬λΆ„ν•΄μ„œ μ €μž₯ν•΄μ•Όν•˜λ‚˜... rdbλŒ€μ‹  λ‹€λ₯Έ dbλ₯Ό κ³ λ €ν•΄λ΄μ•Όν•˜λ‚˜ν•˜κ³  혼자 μ‹¬κ°ν•œ κ³ λ―Όν•˜κ³  μžˆμ—ˆλŠ”λ° κ·Έλƒ₯.......μ΄λ ‡κ²Œ μ°Ύμ•„μ˜€λ©΄ λ˜λŠ”κ±°μ˜€λ„€μš” μ „ λŒ€μ°¬μ„±μž…λ‹ˆλ‹€

@jjongwa jjongwa closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants