GithubHelp home page GithubHelp logo

docs's Introduction

관련자료

참고도서

AWS 접속 URL

카프카 설치

eventTopic 이라는 Topic 에 메세지 통신

  • 토픽 생성
    kafka-topics.bat --zookeeper localhost:2181 --topic eventTopic --create --partitions 1 --replication-factor 1

kubectl -n kafka exec my-kafka-0 -- /usr/bin/kafka-topics --zookeeper my-kafka-zookeeper:2181 --topic eventTopic --create --partitions 1 --replication-factor 1

  • 토픽 리스트 보기
    kafka-topics.bat --zookeeper localhost:2181 --list

kubectl -n kafka exec my-kafka-0 -- /usr/bin/kafka-topics --zookeeper my-kafka-zookeeper:2181 --list

  • 이벤트 발행하기

---- window
bin/windows/kafka-console-producer.bat --broker-list http://localhost:9092 --topic eventTopic

---- mac
bin/kafka-console-producer --broker-list http://localhost:9092 --topic eventTopic

--- cluster
kubectl -n kafka exec -ti my-kafka-0 -- /usr/bin/kafka-console-producer --broker-list my-kafka:9092 --topic eventTopic

  • 이벤트 수신하기

---- window
bin/windows/kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic eventTopic --from-beginning

---- mac
bin/kafka-console-consumer.sh --bootstrap-server http://localhost:9092 --topic eventTopic --from-beginning

---- cluster
kubectl -n kafka exec -ti my-kafka-0 -- /usr/bin/kafka-console-consumer --bootstrap-server my-kafka:9092 --topic eventTopic --from-beginning

카프카 서버의 실행 (필요한 경우만)

---- window

  • (새창)주키퍼 실행
    bin/windows/zookeeper-server-start.bat config/zookeeper.properties
    or
    cd bin/windows
    zookeeper-server-start.bat ../../config/zookeeper.properties

  • (새창)카프카 실행
    bin/windows/kafka-server-start.bat config/server.properties
    or
    cd bin/windows
    kafka-server-start.bat ../../config/server.properties

---- mac (brew 로 설치시)

  • 주키퍼 실행
    zkserver start
  • 카프카 실행
    /usr/local/bin/kafka-server-start /usr/local/etc/kafka/server.properties

이벤트 발송 시나리오

주문이 발생함 – order
주문이 발생함 - 상품 수량 변경됨 - product
주문이 발생함 - 배송 시작됨 – delivery
배송 시작됨 - 배송 완료됨 – delivery
배송 완료됨 - 상품추천 – marketing
설문조사 - 블랙리스트 추가 - service_center
블랙리스트 추가 - mypage

주문 취소함 - order
주문 취소함 - 상품 수량 변경됨 - product
주문이 취소함 - 배송 취소됨 – delivery

1번 시나리오 - ui 없이 order, product, delivery, marketing, service_center 프로젝트를 실행하고 주문이벤트 발생

#### product 서비스 실행시 발생함 - 상품이 입력됨
{"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"}
{"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"}
{"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"}
{"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"}
{"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"}

#### http localhost:8081/orders productId=1 quantity=3 customerId="[email protected]" customerName="홍길동" customerAddr="서울시" 입력시 발생함
{"eventType":"OrderPlaced","timestamp":"20190916151922","stateMessage":"주문이 발생함","productId":2,"orderId":3,"productName":"RADIO","quantity":3,"price":20000,"customerId":"[email protected]","customerName":"홍길동","customerAddr":"서울시"}
{"eventType":"DeliveryStarted","timestamp":"20190916151922","stateMessage":"배송이 시작됨","deliveryId":3,"orderId":3,"customerId":"[email protected]","customerName":"홍길동","deliveryAddress":"서울시","deliveryState":"DeliveryStarted"}
{"eventType":"ProductChanged","timestamp":"20190916151922","stateMessage":"상품 변경이 발생함","productId":2,"productName":"RADIO","productPrice":20000,"productStock":14,"imageUrl":"/goods/img/RADIO.jpg"}
{"eventType":"DeliveryCompleted","timestamp":"20190916151922","stateMessage":"배송이 완료됨","deliveryId":3,"orderId":3,"customerId":"[email protected]","customerName":"홍길동","deliveryAddress":"서울시","deliveryState":"DeliveryCompleted"}

#### http http://localhost:8084/surveys customerId="[email protected]" surveyMessage="nonooooo" productSatisfaction=1 입력시 발생함
{"eventType":"SurveyCompleted","timestamp":"20190905150424","stateMessage":"설문이 완료됨","customerName":"[email protected]","surveyMessage":"nonooooo","productSatisfaction":1}
{"eventType":"BlackListAdded","timestamp":"20190905150424","stateMessage":"블랙리스트로 추가됨","customerId":"[email protected]"}

2번 시나리오 mypage 를 실행 후에, 발생된 이벤트를 모두 받아서 조회를 함

mypage 는 CQRS 모형이며, 그중 READ 부분을 담당한다.
각종 일어난 이벤트들을 받아서, 자신만의 DB 에 저장을 하여 보여주는 서비스이다.

mypage 의 정보는 DB 에 저장을 하여서.. orderid 부분이 안맞을수도 있습니다.

### 유저 정보 조회 -> http http://localhost:8086/users/[email protected]  
{
    "_links": {
        "self": {
            "href": "http://localhost:8086/users/[email protected]"
        },
        "user": {
            "href": "http://localhost:8086/users/[email protected]"
        }
    },
    "accountNonExpired": true,
    "accountNonLocked": true,
    "address": "서울시 논현동",
    "credentialsNonExpired": true,
    "enabled": true,
    "money": 900000,
    "nickname": "유엔진",
    "role": null
}

###  주문 히스토리 조회 -> http http://localhost:8086/mypage/order/[email protected]  
[
    {
        "deliveryCompleted": true,
        "deliveryId": 3,
        "deliveryStarted": true,
        "nickName": "홍길동",
        "orderId": 3,
        "payment": 60000,
        "productId": 2,
        "productName": "RADIO",
        "quantity": 3,
        "timestamp": "20190916151922",
        "userId": "[email protected]"
    }
]

3번 시나리오 ui, gateway, oauth 서버를 띄운후에 화면으로 조회

http://localhost:8080

각 팀별로 event-storming 에 있는 프로젝트를 fork

  • 상품개발팀 같은 경우 event-storming/product 프로젝트에 들어가서 오른쪽 상단의 Fork 버튼 클릭

  • IDE 환경에서 해당 git 소스코드를 clone 받아서 개발 함

git clone https://github.com/event-storming/[username]/products.git

httpie 설치

https://github.com/TheOpenCloudEngine/uEngine-cloud/wiki/Httpie-%EC%84%A4%EC%B9%98

환경변수 등록: windows10 Windows+R 창에서 sysdm.cpl ,3 입력 후 설정

Python 설치 후 httpie 설치 시, SSL Certificate Error 우회 방안 :

  • pip install --trusted-host files.pythonhosted.org httpie

템플릿 프로젝트는 주문이 발생하였을때 연관되어서 이벤트가 발생하도록 설계됨

-- 주문 발생
http localhost:8081/orders productId=1 quantity=3 customerId="[email protected]" customerName="홍길동" customerAddr="서울시"
-- 주문 취소
http PATCH localhost:8081/orders/1 state=OrderCancelled

order 서비스를 실행할때 product 서비스에서 request 방식으로 재고를 체크하고 싶을때는
mvn spring-boot:run -DcheckStock=true
로 order 서비스를 실행하면 됩니다.

docs's People

Contributors

kimscott avatar acmexii avatar jinyoung avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.