├── README.md ├── __교재-Kafka.pdf ├── __교재-AWS-CICD-Pipeline_3.0.pdf ├── __교재-Azure-CICD-Pipeline_3.5.pdf ├── __교재-Developing Cloud Native Application_3.0.pdf ├── __교재-Event Storming based MSA training_3rd_Jan_2020.pdf └── add-to-order /README.md: -------------------------------------------------------------------------------- 1 | ## 관련자료 2 | 3 | - PDF 교재: 4 | https://github.com/event-storming/docs/blob/master/__%E1%84%80%E1%85%AD%E1%84%8C%E1%85%A2-Azure-pipeline.pdf 5 | - 실습스크립트 룩업: 6 | https://workflowy.com/s/msa/27a0ioMCzlpV04Ib 7 | 8 | - 페이스북 그룹 : 9 | https://www.facebook.com/groups/cloudswmoding 10 | 11 | - 이벤트 스토밍 코드 전환 : 12 | http://msaez.io/ 13 | 14 | - 구글 클라우드 : 15 | https://cloud.google.com/ 16 | 17 | - Quick Tour 실습 난이도 조사 : 18 | https://docs.google.com/forms/d/e/1FAIpQLSe0nb4_C8myV23BNgqRevQvoNCEP6OSIlxDtVfRgcunxW39Cw/viewform 19 | 20 | ## 참고도서 21 | 22 | - Overall MSA Design patterns: 23 | https://www.manning.com/books/microservices-patterns 24 | 25 | - Microservice decomposition strategy: 26 | - DDD distilled: https://www.oreilly.com/library/view/domain-driven-design-distilled/9780134434964/ 27 | - Event Storming: https://leanpub.com/introducing_eventstorming 28 | 29 | - Database Design in MSA: 30 | - Lightly: https://www.confluent.io/wp-content/uploads/2016/08/Making_Sense_of_Stream_Processing_Confluent_1.pdf 31 | - Deep dive: https://dataintensive.net/?fbclid=IwAR3OSWkhqRjLI9gBoMpbsk-QGxeLpTYVXIJVCSaw_A5eYrBDc0piKSm4pMM 32 | 33 | - API design and REST: 34 | https://pepa.holla.cz/wp-content/uploads/2016/01/REST-in-Practice.pdf 35 | 36 | ## AWS 접속 URL 37 | - #1. https://kcloud-academy.signin.aws.amazon.com/console 38 | - #2. https://kttestpyj.signin.aws.amazon.com/console 39 | 40 | ## 카프카 설치 41 | - 다운로드 42 | https://kafka.apache.org/downloads ==> 최근 버전의 Scala 2.12 (binary)버전으로 다운로드 43 | 44 | ## eventTopic 이라는 Topic 에 메세지 통신 45 | - 토픽 생성 46 | kafka-topics.bat --zookeeper localhost:2181 --topic eventTopic --create --partitions 1 --replication-factor 1 47 | 48 | kubectl -n kafka exec my-kafka-0 -- /usr/bin/kafka-topics --zookeeper my-kafka-zookeeper:2181 --topic eventTopic --create --partitions 1 --replication-factor 1 49 | 50 | 51 | - 토픽 리스트 보기 52 | kafka-topics.bat --zookeeper localhost:2181 --list 53 | 54 | kubectl -n kafka exec my-kafka-0 -- /usr/bin/kafka-topics --zookeeper my-kafka-zookeeper:2181 --list 55 | 56 | - 이벤트 발행하기 57 | 58 | ---- window 59 | bin/windows/kafka-console-producer.bat --broker-list http://localhost:9092 --topic eventTopic 60 | 61 | ---- mac 62 | bin/kafka-console-producer --broker-list http://localhost:9092 --topic eventTopic 63 | 64 | --- cluster 65 | kubectl -n kafka exec -ti my-kafka-0 -- /usr/bin/kafka-console-producer --broker-list my-kafka:9092 --topic eventTopic 66 | 67 | 68 | - 이벤트 수신하기 69 | 70 | ---- window 71 | bin/windows/kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic eventTopic --from-beginning 72 | 73 | 74 | ---- mac 75 | bin/kafka-console-consumer.sh --bootstrap-server http://localhost:9092 --topic eventTopic --from-beginning 76 | 77 | 78 | ---- cluster 79 | kubectl -n kafka exec -ti my-kafka-0 -- /usr/bin/kafka-console-consumer --bootstrap-server my-kafka:9092 --topic eventTopic --from-beginning 80 | 81 | 82 | ## 카프카 서버의 실행 (필요한 경우만) 83 | ---- window 84 | - (새창)주키퍼 실행 85 | bin/windows/zookeeper-server-start.bat config/zookeeper.properties 86 | or 87 | cd bin/windows 88 | zookeeper-server-start.bat ../../config/zookeeper.properties 89 | 90 | - (새창)카프카 실행 91 | bin/windows/kafka-server-start.bat config/server.properties 92 | or 93 | cd bin/windows 94 | kafka-server-start.bat ../../config/server.properties 95 | 96 | ---- mac (brew 로 설치시) 97 | - 주키퍼 실행 98 | zkserver start 99 | - 카프카 실행 100 | /usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties 101 | 102 | ## 이벤트 발송 시나리오 103 | 104 | 105 | 주문이 발생함 – order 106 | 주문이 발생함 - 상품 수량 변경됨 - product 107 | 주문이 발생함 - 배송 시작됨 – delivery 108 | 배송 시작됨 - 배송 완료됨 – delivery 109 | 배송 완료됨 - 상품추천 – marketing 110 | 설문조사 - 블랙리스트 추가 - service_center 111 | 블랙리스트 추가 - mypage 112 | 113 | 114 | 주문 취소함 - order 115 | 주문 취소함 - 상품 수량 변경됨 - product 116 | 주문이 취소함 - 배송 취소됨 – delivery 117 | 118 | 119 | ## 1번 시나리오 - ui 없이 order, product, delivery, marketing, service_center 프로젝트를 실행하고 주문이벤트 발생 120 | 121 | ``` 122 | #### product 서비스 실행시 발생함 - 상품이 입력됨 123 | {"eventType":"ProductChanged","timestamp":"20190905150002","stateMessage":"상품 변경이 발생함","productId":1,"productName":"TV","productPrice":10000,"productStock":10,"imageUrl":"https://github.githubassets.com/images/modules/profile/profile-joined-github.png"} 124 | {"eventType":"ProductChanged","timestamp":"20190905150002","stateMessage":"상품 변경이 발생함","productId":2,"productName":"RADIO","productPrice":20000,"productStock":20,"imageUrl":"https://github.githubassets.com/images/modules/profile/profile-joined-github.png"} 125 | {"eventType":"ProductChanged","timestamp":"20190905150002","stateMessage":"상품 변경이 발생함","productId":3,"productName":"NOTEBOOK","productPrice":30000,"productStock":30,"imageUrl":"https://github.githubassets.com/images/modules/profile/profile-joined-github.png"} 126 | {"eventType":"ProductChanged","timestamp":"20190905150002","stateMessage":"상품 변경이 발생함","productId":4,"productName":"TABLE","productPrice":40000,"productStock":40,"imageUrl":"https://github.githubassets.com/images/modules/profile/profile-joined-github.png"} 127 | {"eventType":"ProductChanged","timestamp":"20190905150002","stateMessage":"상품 변경이 발생함","productId":5,"productName":"CLOCK","productPrice":50000,"productStock":50,"imageUrl":"https://github.githubassets.com/images/modules/profile/profile-joined-github.png"} 128 | 129 | #### http localhost:8081/orders productId=1 quantity=3 customerId="1@uengine.org" customerName="홍길동" customerAddr="서울시" 입력시 발생함 130 | {"eventType":"OrderPlaced","timestamp":"20190916151922","stateMessage":"주문이 발생함","productId":2,"orderId":3,"productName":"RADIO","quantity":3,"price":20000,"customerId":"1@uengine.org","customerName":"홍길동","customerAddr":"서울시"} 131 | {"eventType":"DeliveryStarted","timestamp":"20190916151922","stateMessage":"배송이 시작됨","deliveryId":3,"orderId":3,"customerId":"1@uengine.org","customerName":"홍길동","deliveryAddress":"서울시","deliveryState":"DeliveryStarted"} 132 | {"eventType":"ProductChanged","timestamp":"20190916151922","stateMessage":"상품 변경이 발생함","productId":2,"productName":"RADIO","productPrice":20000,"productStock":14,"imageUrl":"/goods/img/RADIO.jpg"} 133 | {"eventType":"DeliveryCompleted","timestamp":"20190916151922","stateMessage":"배송이 완료됨","deliveryId":3,"orderId":3,"customerId":"1@uengine.org","customerName":"홍길동","deliveryAddress":"서울시","deliveryState":"DeliveryCompleted"} 134 | 135 | #### http http://localhost:8084/surveys customerId="1@uengine.org" surveyMessage="nonooooo" productSatisfaction=1 입력시 발생함 136 | {"eventType":"SurveyCompleted","timestamp":"20190905150424","stateMessage":"설문이 완료됨","customerName":"1@uengine.org","surveyMessage":"nonooooo","productSatisfaction":1} 137 | {"eventType":"BlackListAdded","timestamp":"20190905150424","stateMessage":"블랙리스트로 추가됨","customerId":"1@uengine.org"} 138 | 139 | ``` 140 | ## 2번 시나리오 mypage 를 실행 후에, 발생된 이벤트를 모두 받아서 조회를 함 141 | mypage 는 CQRS 모형이며, 그중 READ 부분을 담당한다. 142 | 각종 일어난 이벤트들을 받아서, 자신만의 DB 에 저장을 하여 보여주는 서비스이다. 143 | > mypage 의 정보는 DB 에 저장을 하여서.. orderid 부분이 안맞을수도 있습니다. 144 | 145 | ``` 146 | ### 유저 정보 조회 -> http http://localhost:8086/users/1@uengine.org 147 | { 148 | "_links": { 149 | "self": { 150 | "href": "http://localhost:8086/users/1@uengine.org" 151 | }, 152 | "user": { 153 | "href": "http://localhost:8086/users/1@uengine.org" 154 | } 155 | }, 156 | "accountNonExpired": true, 157 | "accountNonLocked": true, 158 | "address": "서울시 논현동", 159 | "credentialsNonExpired": true, 160 | "enabled": true, 161 | "money": 900000, 162 | "nickname": "유엔진", 163 | "role": null 164 | } 165 | 166 | ### 주문 히스토리 조회 -> http http://localhost:8086/mypage/order/1@uengine.org 167 | [ 168 | { 169 | "deliveryCompleted": true, 170 | "deliveryId": 3, 171 | "deliveryStarted": true, 172 | "nickName": "홍길동", 173 | "orderId": 3, 174 | "payment": 60000, 175 | "productId": 2, 176 | "productName": "RADIO", 177 | "quantity": 3, 178 | "timestamp": "20190916151922", 179 | "userId": "1@uengine.org" 180 | } 181 | ] 182 | 183 | ``` 184 | 185 | ## 3번 시나리오 ui, gateway, oauth 서버를 띄운후에 화면으로 조회 186 | http://localhost:8080 187 | 188 | 189 | 190 | ## 각 팀별로 event-storming 에 있는 프로젝트를 fork 191 | 192 | - 상품개발팀 같은 경우 event-storming/product 프로젝트에 들어가서 오른쪽 상단의 Fork 버튼 클릭 193 | 194 | - IDE 환경에서 해당 git 소스코드를 clone 받아서 개발 함 195 | 196 | ``` 197 | git clone https://github.com/event-storming/[username]/products.git 198 | ``` 199 | 200 | ## httpie 설치 201 | 202 | https://github.com/TheOpenCloudEngine/uEngine-cloud/wiki/Httpie-%EC%84%A4%EC%B9%98 203 | 204 | 환경변수 등록: windows10 Windows+R 창에서 **sysdm.cpl ,3** 입력 후 설정 205 | 206 | Python 설치 후 httpie 설치 시, SSL Certificate Error 우회 방안 : 207 | - pip install --trusted-host files.pythonhosted.org httpie 208 | 209 | 210 | ## 템플릿 프로젝트는 주문이 발생하였을때 연관되어서 이벤트가 발생하도록 설계됨 211 | -- 주문 발생 212 | http localhost:8081/orders productId=1 quantity=3 customerId="1@uengine.org" customerName="홍길동" customerAddr="서울시" 213 | -- 주문 취소 214 | http PATCH localhost:8081/orders/1 state=OrderCancelled 215 | 216 | >> order 서비스를 실행할때 product 서비스에서 request 방식으로 재고를 체크하고 싶을때는 217 | >> mvn spring-boot:run -DcheckStock=true 218 | >> 로 order 서비스를 실행하면 됩니다. 219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /__교재-Kafka.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/event-storming/docs/1a2f273e79011c4ed7f03f261f07dd07cc2f8152/__교재-Kafka.pdf -------------------------------------------------------------------------------- /__교재-AWS-CICD-Pipeline_3.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/event-storming/docs/1a2f273e79011c4ed7f03f261f07dd07cc2f8152/__교재-AWS-CICD-Pipeline_3.0.pdf -------------------------------------------------------------------------------- /__교재-Azure-CICD-Pipeline_3.5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/event-storming/docs/1a2f273e79011c4ed7f03f261f07dd07cc2f8152/__교재-Azure-CICD-Pipeline_3.5.pdf -------------------------------------------------------------------------------- /__교재-Developing Cloud Native Application_3.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/event-storming/docs/1a2f273e79011c4ed7f03f261f07dd07cc2f8152/__교재-Developing Cloud Native Application_3.0.pdf -------------------------------------------------------------------------------- /__교재-Event Storming based MSA training_3rd_Jan_2020.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/event-storming/docs/1a2f273e79011c4ed7f03f261f07dd07cc2f8152/__교재-Event Storming based MSA training_3rd_Jan_2020.pdf -------------------------------------------------------------------------------- /add-to-order: -------------------------------------------------------------------------------- 1 | @PrePersist 2 | public void onPrePersist(){ 3 | try { 4 | Thread.currentThread().sleep((long) (800 + Math.random() * 220)); 5 | } catch (InterruptedException e) { 6 | e.printStackTrace(); 7 | } 8 | } 9 | --------------------------------------------------------------------------------