{"id":25899457,"url":"https://github.com/ingkellswith/msa-gift-dev","last_synced_at":"2026-04-18T07:33:42.339Z","repository":{"id":193706750,"uuid":"414665349","full_name":"ingkellswith/msa-gift-dev","owner":"ingkellswith","description":"DDD를 Spring Boot에 적용한 Repository입니다. 🧾주문 서비스와 분리된 🎀선물하기 서비스를 구현합니다.  다른 서비스(🧾주문 서비스)와 통신하는 방법으로 aws sqs를 사용합니다. (연계 repository : msa-order-dev)","archived":false,"fork":false,"pushed_at":"2021-12-12T09:49:29.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T23:37:03.442Z","etag":null,"topics":["ddd","message-queue","msa","spring-boot","spring-mvc"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ingkellswith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-07T15:53:17.000Z","updated_at":"2021-12-12T09:49:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"4303d039-ec56-4528-a0d4-0f0a5a839675","html_url":"https://github.com/ingkellswith/msa-gift-dev","commit_stats":null,"previous_names":["ingkellswith/msa-gift-dev"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ingkellswith/msa-gift-dev","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingkellswith%2Fmsa-gift-dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingkellswith%2Fmsa-gift-dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingkellswith%2Fmsa-gift-dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingkellswith%2Fmsa-gift-dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ingkellswith","download_url":"https://codeload.github.com/ingkellswith/msa-gift-dev/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingkellswith%2Fmsa-gift-dev/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd","message-queue","msa","spring-boot","spring-mvc"],"created_at":"2025-03-03T01:28:52.860Z","updated_at":"2026-04-18T07:33:42.300Z","avatar_url":"https://github.com/ingkellswith.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"msa-gift-dev\n==============\n(수강 강의 - 패스트캠퍼스, The RED : 비즈니스 성공을 위한 Java/Spring 기반 서비스 개발과 MSA 구축 by 이희창)\n\nrepository 주제 : ddd, msa 구현\n\nmsa-gift-dev에서는 [msa-order-dev](https://github.com/ingkellswith/msa-order-dev) 에서 구현한 주문 서비스와 통신합니다\n\n# 선물하기 기능 기본 설계\n1. msa-order-dev repository에서 파트너, 상품, 주문(결제까지) 도메인 서비스를 구현했다\n2. msa를 위해 선물 도메인 서비스는 이 repository에서 구현하고, msa-order-dev에 있는 주문, 결제 처리가 필요한 상황\n3. 선물하기 주문 작업은 1) 선물하기 주문 정보 등록 2) 선물하기 요청에 맞는 주문 정보 생성 3) 결제 처리 4) 선물 지급 등으로 구성\n4. 따라서 2), 3)은 msa-order-dev에서 처리 1), 4)는 msa-gift-dev에서 처리\n5. 이미 운영중인 주문 도메인 서비스에 결제 정보 생성과 결제 처리를 위한 메시지를 정의해야 한다.\n- 일반 주문과 다르게 선물하기 주문은 결제 과정에서는 배송지 정보가 fix 되지 않기 때문에, 기존의 일반 주문 메시지와는 약간 다른 메시지 형태를 가진다\n- 그런데 배송지 정보를 필수로 가져가는 식의 @Embeddable fragment로 구현한 상황\n- 문제 상황 해결을 위한 방안 3가지 존재\n- a) 기존 msa-order-dev의 api변경\n- b) 기존 msa-order-dev에서 v2로 신규 api생성\n- c) 신규 msa-gift-dev에서 배송지 정보에 선물하기 기능에서만 사용할 식별가능한 temp값 넣기\n- 이 프로젝트에서는 c)방안을 채택해 진행 \n- c)방안은 기존 서비스들의 로직을 변경할 필요가 없다는 장점이 존재\n- 메시지 큐를 사용하지 않을 경우 양방향 의존 관계가 생김  \n- 메시지 큐를 사용함으로써 서버 간 결합 관계 느슨\n- 메시지 큐에 성공 메시지만 보내면 성공 메시지를 수신할 대상은 신경쓸 필요가 없다\n- 선물하기 서버가 장애 상황이라도 서비스 복구 후에 메시지 큐의 메시지를 읽어 주문 성공 처리가능  \n\n(메시지 큐를 사용하지 않을 때의 구조)  \n\n![nosqs](https://user-images.githubusercontent.com/55550753/136477754-fd6e5b52-9a73-4406-bfe2-a014464fbd2c.PNG)  \n7. 따라서 메시지 기반 비동기 통신을 사용해 '주문 서비스 → 선물하기 서비스'의 방향성을 제거한다  \n\n![withsqs](https://user-images.githubusercontent.com/55550753/136477898-f2be5514-e759-4522-b6bb-a6003b96c871.PNG)  \n\n# 메시지 큐를 이용한 msa설계\n\n- sequence diagram : 선물 구매시  \n\n![msawithsqs](https://user-images.githubusercontent.com/55550753/136494089-eceb77ca-4e4d-40d9-9921-7e798e7c72bd.png)  \n\n- sequence diagram : 선물 수락시  \n\n![msa-gift-accept](https://user-images.githubusercontent.com/55550753/136478722-c8d86ace-a1c2-465a-bb16-9d5f9febd0eb.PNG)  \n\n- sequence diagram : 선물 거절시  \n\n![msa-gift-deny](https://user-images.githubusercontent.com/55550753/136478912-9638ca3b-e51b-499c-ab79-45d55b09e8ad.PNG)  \n\n# 참고 : kafka(이 프로젝트에서 사용하지 않음)\n#### kafka 의 multi consumer 구조를 활용한다면, 주문 서비스를 활용하는 클라이언트가 지속적으로 추가되어도 모든 클라이언트가 결제 성공 메시지를 전달 받을 수 있다  \n![kafkabasic](https://user-images.githubusercontent.com/55550753/136479313-dc930dc2-47ac-4f06-8c4b-0d6387e722c9.PNG)\n\n- 다만 메시지 내부에는 해당 주문의 클라이언트가 어디인지를 구분하는 구분값이 있어야하고, 각 클라이언트는 자신의 메시지인지를 확인하는 필터링 로직이 추가되어야 하는 단점이 있다\n- 예를 들어 주식 서비스에서 주문 서비스를 통해 결제 처리를 요청했고 주문 서비스가 결제 성공 메시지를 발행한다면, 해당 메시지 내부에는 serviceType=\"주식\" 과 같은 프로퍼티가 추가되어야 한다\n- kafka 의 주문 성공 topic 을 consuming 하는 다양한 서비스들은 동일한 메시지를 수신할 것이기 때문에 주식 서비스 이외에는 결제 성공 로직을 처리하지 않도록 필터링 로직을 구현해야 한다\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingkellswith%2Fmsa-gift-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fingkellswith%2Fmsa-gift-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingkellswith%2Fmsa-gift-dev/lists"}