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

Feat/#378 event driven architecture #379

Merged
merged 80 commits into from
Jul 17, 2024

Conversation

JIN-076
Copy link
Collaborator

@JIN-076 JIN-076 commented Jul 1, 2024

๐Ÿš€ ๊ฐœ๋ฐœ ์‚ฌํ•ญ

์—…์  ์ด๋ฒคํŠธ ์•„ํ‚คํ…์ฒ˜ ์„ค๊ณ„๋„
Untitled

config ํด๋ž˜์Šค
KafkaProducerConfig
kafkaConsumerConfig

์ปค์Šคํ…€ ๋ฉ”์‹œ์ง€ ํƒ€์ž…์„ ์œ„ํ•œ ์—ญ์ง๋ ฌํ™” ํด๋ž˜์Šค
CustomDeserializer

  • ์ปจ์Šˆ๋จธ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ byte๋กœ ์ˆ˜์‹ ํ•˜๊ณ  ์ด์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ์—ญ์ง๋ ฌํ™”ํ•˜๋Š” ๊ณผ์ •์—์„œ (Event<?> ํƒ€์ž…์œผ๋กœ) CustomDeserializer ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์ฒ˜๋ฆฌํ•จ

๋ฉ”์‹œ์ง€ ์ค‘๋ณต ์ฒ˜๋ฆฌ ๋ฐฉ์ง€๋ฅผ ์œ„ํ•œ ์ปดํฌ๋„ŒํŠธ
Event<T>
MessageLog
DuplicateLogService

producer ยท consumer ์ปดํฌ๋„ŒํŠธ
MessageProducer
AcheivementMessageConsumer
NotificationMessageConsumer
MailSender

  • ์นดํ”„์นด๋ฅผ ํ™œ์šฉํ•œ ๋ฉ”์‹œ์ง€ ์ „์†ก ๋ฐ ์ˆ˜์‹ ์œผ๋กœ ์ธํ•œ ์ฒ˜๋ฆฌ ๊ณผ์ •์—์„œ, ์ •ํ™•ํžˆ ํ•œ ๋ฒˆ ์ „์†ก๊ณผ ๋ฉ”์‹œ์ง€์˜ ์ค‘๋ณต ์ฒ˜๋ฆฌ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ์ปดํฌ๋„ŒํŠธ
  • ํ”„๋กœ๋“€์„œ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ํŠธ๋žœ์žญ์…˜ ๋‹จ์œ„๋กœ ์ „์†กํ•˜๋ฉฐ, ์ •ํ™•ํžˆ ํ•œ ๋ฒˆ ์ „์†ก EOS ๋ฅผ ์œ„ํ•ด ๋ฉฑ๋“ฑ์„ฑ์„ ๋ณด์žฅ, transaction_id_prefix๋ฅผ ์„ค์ •ํ•จ
  • ์ปจ์Šˆ๋จธ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 5๊ฐœ๋ฅผ ์ˆ˜์‹ ํ•  ์ˆ˜ ์žˆ๋„๋ก, ๋ฉ”์‹œ์ง€์˜ ์ค‘๋ณต๊ณผ ์†์‹ค์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์˜คํ”„์…‹์„ ์ˆ˜๋™์œผ๋กœ ์ปค๋ฐ‹ํ•˜๋„๋ก ํ•จ
  • ์˜คํ”„์…‹์€ ์ตœ๋Œ€ 5๊ฐœ์˜ ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ˆ˜๋™์œผ๋กœ ์ปค๋ฐ‹์ด ๋˜๋ฉฐ, ์ด ๋–„ ์นดํ”„์นด์˜ ์žฅ์• ๋กœ ์ธํ•œ Rebalancing์œผ๋กœ ์ธํ•ด ๋งค์‹œ์ง€ ์ค‘๋ณต ๊ฐ€๋Šฅ์„ฑ ์กด์žฌ
  • ๋ฉ”์‹œ์ง€ ์ค‘๋ณต์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด log๋ฅผ RDBMS์— ๋ณ„๋„๋กœ ์ €์žฅํ•˜๋„๋ก ํ•˜๊ณ , ์ค‘๋ณต ๊ฒ€์‚ฌ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ๊ตฌํ˜„ํ•จ
  • ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ์žฅ์• ๋กœ, ์„ค์ •ํ•ด๋‘” ์žฌ์‹œ๋„ ํšŸ์ˆ˜๋ฅผ ์ดˆ๊ณผํ•˜๋ฉด ๋ฉ”์‹œ์ง€๋Š” ๋ณ„๋„ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด DLT๋กœ ์ด๋™ํ•˜๊ฒŒ ๋˜๊ณ , ์ด๋•Œ ๊ด€๋ฆฌ์ž์˜ ์ด๋ฉ”์ผ๋กœ ์•Œ๋ฆผ์ด ์ „์†ก๋จ

Transactional Outbox Pattern ์ ์šฉ
OutboxEvent
OutboxProcessor

  • Spring์—์„œ ์ œ๊ณตํ•˜๋Š” Event ํ™œ์šฉ ๋ฐฉ์‹์—์„œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์™ธ ๋ณต๊ตฌ๋ฅผ ์œ„ํ•œ ๋””์ž์ธ ํŒจํ„ด ์ ์šฉ
  • ๋„๋ฉ”์ธ ๋กœ์ง์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ˆ˜ํ–‰๋˜์—ˆ์„ ๊ฒฝ์šฐ, ์ด๋ฒคํŠธ ๋ฐœํ–‰ ์™„๋ฃŒ๋ฅผ outbox ํ…Œ์ด๋ธ”์— ๊ธฐ๋ก
  • ์นดํ”„์นด์—์„œ ์„ฑ๊ณต์ ์œผ๋กœ ์ด๋ฒคํŠธ๋ฅผ ๋„˜๊ฒจ๋ฐ›์•˜์„ ๊ฒฝ์šฐ, '์™„๋ฃŒ' ์ƒํƒœ๋กœ ์—…๋ฐ์ดํŠธ
  • ๋ฐœํ–‰ ๋˜๋Š” ์ˆ˜์‹  ์‹คํŒจํ•œ ์ด๋ฒคํŠธ์— ๋Œ€ํ•ด์„œ๋Š” ๋ณ„๋„ ํ”„๋กœ์„ธ์„œ๊ฐ€ ์ฃผ๊ธฐ์ ์œผ๋กœ ์žฌ๋ฐœํ–‰์„ ์ˆ˜ํ–‰ํ•จ์œผ๋กœ์จ ๋ฐ์ดํ„ฐ ์ •ํ•ฉ์„ฑ์„ ๋ณต๊ตฌ

์ด๋ฒคํŠธ ํ—ฌํผ ํด๋ž˜์Šค
ProjectEventHelper
ReviewEventHelper
ProjectJoinRequestEventHelper
ProfileCardLikeEventHelper
NotificationEventHelper

  • ๋„๋ฉ”์ธ ๋กœ์ง๊ณผ ์นดํ”„์นด ๋กœ์ง ๊ฐ„์˜ ๋Š์Šจํ•œ ๊ฒฐํ•ฉ์„ ์œ„ํ•œ ํ—ฌํผ ํด๋ž˜์Šค
  • Spring์—์„œ ์ œ๊ณตํ•˜๋Š” EventPublisher, TransactionalEventListener๋ฅผ ํ™œ์šฉํ•ด ์ด๋ฒคํŠธ ๋ฐœํ–‰ ๋ฐ ์ˆ˜์‹  ์ฒ˜๋ฆฌ

์ด์Šˆ ๋ฒˆํ˜ธ

ํŠน์ด ์‚ฌํ•ญ ๐Ÿซถ

์—…์  ์ด๋ฒคํŠธ ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์„ค๊ณ„ํ•˜๋Š” ๊ณผ์ •์—์„œ, ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ฐœ๋ฐœํ•˜๊ณ  ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์™ธ ์ƒํ™ฉ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ ๊ณผ์ •, ์—๋Ÿฌ ํ•ธ๋“ค๋Ÿฌ ์ฒ˜๋ฆฌ ๋ฐฉ์‹ ๋“ฑ ์ž์„ธํ•œ ๊ฐœ๋ฐœ ๊ณผ์ •์€ ๋‹ค์Œ ๋งํฌ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!
A-Z๊นŒ์ง€ ์—…์  ์ด๋ฒคํŠธ ์•„ํ‚คํ…์ฒ˜ ์žฌ์„ค๊ณ„ ์ •๋ณต๊ธฐ

ํ”ผ๋“œ๋ฐฑ์ด๋‚˜ ๊ถ๊ธˆํ•œ ์ ์— ๋Œ€ํ•ด์„œ๋Š” ๊ฐ€๊ฐ์—†์ด ์ฝ”๋ฉ˜ํŠธ ํ•ด์ฃผ์„ธ์š”~!๐Ÿ™‡๐Ÿปโ€โ™€๏ธ

โ€ฆProducer๋ฅผ ์ด์šฉํ•œ ๋ฉ”์‹œ์ง€ ๋ฐœํ–‰, ์ด๋ฒคํŠธ ๋ฐœํ–‰ ๊ธฐ๋ก ๋กœ์ง ๊ตฌํ˜„
โ€ฆtern ๊ตฌํ˜„์„ ์œ„ํ•œ ์ด๋ฒคํŠธ ์ €์žฅ ๋กœ์ง ๊ตฌํ˜„, ์ด๋ฒคํŠธ ๋ฐœํ–‰ ๋กœ์ง ๊ตฌํ˜„
โ€ฆoducer๋ฅผ ์ด์šฉํ•œ ๋ฉ”์‹œ์ง€ ๋ฐœํ–‰, ์ด๋ฒคํŠธ ๋ฐœํ–‰ ์ •๋ณด๋ฅผ ๊ธฐ๋กํ•˜๋Š” ๋กœ์ง ๊ตฌํ˜„
โ€ฆ๋น„๋ฅผ ํ•˜๊ธฐ ์œ„ํ•œ Event<?> ํƒ€์ž… CustomDeserializer ์„ค์ • ์ถ”๊ฐ€ ๋ฐ ๋ณ€๊ฒฝ
โ€ฆ๋ก ๋กœ์ง ์ˆ˜์ •, ์กฐํšŒ์ˆ˜์— ๊ธฐ๋ฐ˜ํ•œ TTL ์ฆ๊ฐ€ ๋กœ์ง ๊ตฌํ˜„, ๋””๋น„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฏธ๋ฆฌ ์บ์‹ฑํ•˜๋Š” CacheWarning ๋กœ์ง ๊ตฌํ˜„,
@JIN-076 JIN-076 added the โญ๏ธ Feat ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ label Jul 1, 2024
@JIN-076 JIN-076 requested a review from tidavid1 July 1, 2024 15:25
@JIN-076 JIN-076 self-assigned this Jul 1, 2024
Copy link

github-actions bot commented Jul 1, 2024

Test Results

76 testsโ€‚โ€ƒโ€ƒ76 โœ…โ€ƒโ€ƒ2s โฑ๏ธ
11 suitesโ€ƒโ€ƒโ€‡0 ๐Ÿ’ค
11 filesโ€„โ€‚โ€ƒโ€ƒโ€‡0 โŒ

Results for commit d25971d.

โ™ป๏ธ This comment has been updated with latest results.

Copy link
Member

@tidavid1 tidavid1 left a comment

Choose a reason for hiding this comment

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

Transaction OutBox ํŒจํ„ด์„ ์ ์šฉํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š” ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

@JIN-076 JIN-076 closed this Jul 3, 2024
@JIN-076
Copy link
Collaborator Author

JIN-076 commented Jul 3, 2024

Transaction OutBox ํŒจํ„ด์„ ์ ์šฉํ•œ ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š” ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

๋„๋ฉ”์ธ ๋กœ์ง๊ณผ ์นดํ”„์นด ๋กœ์ง ์‚ฌ์ด์˜ ๋Š์Šจํ•œ ๊ฒฐํ•ฉ์„ ์œ„ํ•ด Spring์—์„œ ์ œ๊ณตํ•˜๋Š” Event๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, ์ด๋•Œ ์ด๋ฒคํŠธ ๋ฐœํ–‰๊ณผ ์ด๋ฒคํŠธ ์ˆ˜์‹ ์ด ์‹คํŒจํ–ˆ์„ ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ฐ€ ์Šคํ”„๋ง์—์„œ๋Š” ์ œ๊ณต์ด ๋˜๊ณ  ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค! ์‹ฌ์ง€์–ด ์‹คํŒจํ•ด๋„ ์˜ˆ์™ธ๊ฐ€ ์ „ํŒŒ๋˜์ง€๋„ ์•Š์Šต๋‹ˆ๋‹ค,, ๊ทธ๋ž˜์„œ ํ•ด๋‹น ํŒจํ„ด์„ ์ ์šฉํ•ด์„œ ์ด๋ฒคํŠธ ๋ฐœํ–‰ ์ •๋ณด๋ฅผ ๊ธฐ๋กํ•ด๋‘๊ณ , ๋ฐœํ–‰์ด๋‚˜ ์ˆ˜์‹ ์ด ์‹คํŒจํ•œ ์ด๋ฒคํŠธ๋ฅผ ๋ณ„๋„๋กœ ์žฌ๋ฐœํ–‰ํ•ด์ฃผ๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค!

@JIN-076 JIN-076 reopened this Jul 3, 2024
@JIN-076 JIN-076 changed the title Feat/#378 event driven architecture (์ž‘์„ฑ์ค‘) Feat/#378 event driven architecture Jul 8, 2024
@JIN-076 JIN-076 merged commit 572be3e into develop Jul 17, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
โญ๏ธ Feat ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ
Projects
None yet
2 participants