cej55 / carsharing

car-sharing msa
0 stars 2 forks source link

소스구현 #3

Open cej55 opened 3 years ago

cej55 commented 3 years ago

<<< 소스 구현 >>>

  1. cmd 5개 실행 및 카프카실행
  2. Visual Studio Code > carsharing 폴더 선택
  3. 에약 서비스 구현 및 실행
  4. 결재서비스 구현 및 실행
  5. 대여 서비스 구현 및 실행
  6. 고객 서비스 구현 및 실행
  7. 게이트웨이(프런트 통합채널 포트) 설정 및 실행
  8. 전체시나리오 실행

서비스 확인 cmd 창에서 http url <예약> http http://localhost:8081/reservations == 사용안함 http POST localhost:8081/reservations carId="100" lentalAddr="addr1" retriveAddr="addr2" amount="1000" userPhone="6401" payType="1" payNumber="123" payCompany="bank" => 예약 http “http://localhost:8081/reservations/1” => 조회
<결재> http http://localhost:8083/payments <대여> http http://localhost:8082/rentals <고객> http http://localhost:8084/customers http http://localhost:8084/myPages 서비스 command 브라우저 url(통합채널 포트) <예약> http://localhost:8088/reserve_action.html <예약 취소> http://localhost:8088/cancel_action.html <예약 반납> http://localhost:8088/return_action.html <차량 대여> http://localhost:8088/rental_action.html <차량 회수> http://localhost:8088/retrieve_action.html

  1. cmd 5개 실행 및 카프카실행 1.1 cmd 5개 실행
    cmd 1번 : 카프카/서비스 포트 실행 확인 용
    cmd 2번 : 카프라 주키퍼 실행 cmd 3번 : 카프카 실행 cmd 4번 : 카프카 이벤트 확인(토픽명 : carsharing) cmd 5번 : 예약/결재 http client 에서 서비스 호출 실행 h

    1.2 카프카실행 C:\tmp내 폴더 2개 삭제 초기화(카프카 이력 파일, 예전 데이터 초기화) cmd 2/3/4번 카프카 설치폴더\bin\window 이동 cmd 2번 zookeeper-server-start.bat ../../config/zookeeper.properties cmd 3번 kafka-server-start.bat ../../config/server.properties cmd 4번 kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning

    • 실행 포트 확인 및 삭제 netstat -ano | findstr "PID :2181" -> 주키퍼실행 확인 netstat -ano | findstr "PID :9092" -> 카프카실행 확인 netstat -ano | findstr "PID :808" -> 마이크로 서비스 도메인서비스(게이트웨이) 확인 taskkill /pid 99999 /f -> 포트 삭제

    • 카프카메세지 토픽 생성/ 보내기/받기 => 목차: 구현 > 이벤트 기반 메시지 채널 로컬 환경에서 토픽을 생성 하여 해당 토픽에서 메세지를 pub/sub 해보기 토픽생성: kafka-topics.bat --zookeeper localhost:2181 --topic carsharing --create --partitions 1 --replication-factor 1 토픽확인: kafka-topics.bat --zookeeper localhost:2181 --list 이벤트 발행하기(프로바이드(pub),토픽조인) : kafka-console-producer.bat --broker-list http://localhost:9092 --topic carsharing 이벤트 수신하기(컨슈머(sub),포픽조인 읽기전용) : kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning

  2. Visual Studio Code > carsharing 폴더 선택
  3. 에약 서비스 구현 및 실행 3.1 서비스 포트 확인 : reservation/src/main/resource/application.yml spring > profiles : default port : 8081 3.2 구현 3.2.1 외부 동기식(Req/Res) 호출 외부 함수 정의 rservation/src/main/java/external/PaymentService.java

@FeignClient(name="payment", url="${api.payment.url}") // payment url => http://localhost:8083 public interface PaymentService {

@RequestMapping(method= RequestMethod.POST, path="/pay")        
public boolean pay(@RequestParam("reserveId") String reserveId,
            @RequestParam("carId") String carId,
            @RequestParam("amount") String amount,
            @RequestParam("userPhone") String userPhone,
            @RequestParam("payType") String userpayType,
            @RequestParam("payNumber") String payNumber,
            @RequestParam("payCompany") String payCompany);

}

 3.2.2 command (예약/반납/취소/configMap 환경변수 조회) 구현
   reservation/src/main/java/carsharing/ReservationController.java

@RestController public class ReservationController { @Autowired ReservationRepository reservationRepository;

@RequestMapping(value = "/env",
method = RequestMethod.GET,
produces = "application/json;charset=UTF-8")

public void env(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /env  called #####");

    String env_DB_IP = System.getenv("DB_IP");
    String env_DB_SERVICE_NAME = System.getenv("DB_SERVICE_NAME");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    PrintWriter writer = response.getWriter();
    writer.write("DB IP : " + env_DB_IP +"\r\n");
    writer.write("DB SERVICE_NAME : " + env_DB_SERVICE_NAME);
    writer.flush();
    writer.close();
}

@RequestMapping(value = "/reserve",
method = RequestMethod.POST,
produces = "application/json;charset=UTF-8")

public String reserve(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /reserve  called #####");

    String carId = request.getParameter("carId");
    String rentalAddr = request.getParameter("rentalAddr");
    String retrieveAddr = request.getParameter("retriveAddr");
    String userPhone = request.getParameter("userPhone");
    Long amount = Long.parseLong(request.getParameter("amount"));
    String reserveDate = request.getParameter("reserveDate");
    String payType = request.getParameter("payType");
    String payNumber = request.getParameter("payNumber");
    String payCompany = request.getParameter("payCompany");

    System.out.println("##### carId : " + carId);
    System.out.println("##### amount : " + amount);
    System.out.println("##### userPhone : " + userPhone);
    System.out.println("##### payType : " + payType);
    System.out.println("##### payNumber : " + payNumber);
    System.out.println("##### payCompany : " + payCompany);

    Reservation reservation = new Reservation();
    reservation.setCarId(carId);
    reservation.setRentalAddr(rentalAddr);
    reservation.setRetrieveAddr(retrieveAddr);
    reservation.setUserPhone(userPhone);
    reservation.setAmount(amount);
    reservation.setReserveDate(reserveDate);
    reservation.setPayType(payType);
    reservation.setPayNumber(payNumber);
    reservation.setPayCompany(payCompany);

    reservation  = reservationRepository.save(reservation);

    String reserveId = Long.toString(reservation.getId());        
    System.out.println("##### reserveId : " + reserveId);

    boolean ret = false;
    try {
        ret = ReservationApplication.applicationContext.getBean(carsharing.external.PaymentService.class)
            .pay(reserveId, carId, String.valueOf(amount), userPhone, payType, payNumber, payCompany);

        System.out.println("##### /payment/pay  called result : " + ret);
    } catch (Exception e) {
        System.out.println("##### /payment/pay  called exception : " + e);
    }

    String status = "";
    if (ret) {
        status = "Reserved";
    } else {
        status = "ReserveFailed";
    } 

    reservation.setReserveStatus(status);
    reservation  = reservationRepository.save(reservation);

    return status;
}

@RequestMapping(value = "/cancel",
method = RequestMethod.POST,
produces = "application/json;charset=UTF-8")

public String cancel(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /cancel  called #####");

    String reserveId = request.getParameter("reserveId");
    String cancelDate = request.getParameter("cancelDate");        
    System.out.println("##### reserveId : " + reserveId);
    System.out.println("##### cancelDate : " + cancelDate);        

    Optional<Reservation> reservationOptional = ReservationApplication.applicationContext.getBean(carsharing.ReservationRepository.class)
              .findById(Long.parseLong(reserveId));

    String status = "ReserveCanceled";          

    if (reservationOptional.isEmpty() == false) {
        Reservation reservation = reservationOptional.get();
        String curStatus = reservation.getReserveStatus();
        if ("Reserved".equals(curStatus)) {
            reservation.setCancelDate(cancelDate);
            reservation.setReserveStatus(status);
            ReservationApplication.applicationContext.getBean(carsharing.ReservationRepository.class)
            .save(reservation);
            }
        else {
            status = "reserve status is not Reserved(current : " + curStatus + ")"; 
        }
    }
    else{
        status = "not found reserveId : " + reserveId; 
    }     

    return status;          
}

@RequestMapping(value = "/resreturn",
method = RequestMethod.POST,
produces = "application/json;charset=UTF-8")

public String resreturn(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /resreturn  called #####");

    String reserveId = request.getParameter("reserveId");
    String returnDate = request.getParameter("returnDate");        
    System.out.println("##### reserveId : " + reserveId);
    System.out.println("##### returnDate : " + returnDate);

    Optional<Reservation> reservationOptional = ReservationApplication.applicationContext.getBean(carsharing.ReservationRepository.class)
              .findById(Long.parseLong(reserveId));

    String status = "ReserveReturned";                     
    if (reservationOptional.isEmpty() == false) {
        Reservation reservation = reservationOptional.get();
        String curStatus = reservation.getReserveStatus();
        if ("Reserved".equals(curStatus)) {            
            reservation.setReturnDate(returnDate);
            reservation.setReserveStatus(status);

            ReservationApplication.applicationContext.getBean(carsharing.ReservationRepository.class)
            .save(reservation);
        }
        else {
            status = "reserve status is not Reserved(current : " + curStatus + ")"; 
        }            
    }   
    else{
        status = "not found reserveId : " + reserveId; 
    } 

    return status;                         
}   

 3.2.3 이벤트 송출(예약됨, 반납됨, 취소됨) 구현
   reservation/src/main/java/carsharing/Reservation.java

@PostUpdate
public void onPostUpdate(){
    if ("Reserved".equals(this.getReserveStatus()))
    {
        Reserved reserved = new Reserved();
        BeanUtils.copyProperties(this, reserved);
        reserved.publishAfterCommit();
        System.out.println("##### send event : Reserved  #####");   
    } 
    else if ("ReserveCanceled".equals(this.getReserveStatus()))
    {
        ReserveCanceled reserveCanceled = new ReserveCanceled();
        BeanUtils.copyProperties(this, reserveCanceled);
        reserveCanceled.publishAfterCommit();
    }               
    else if ("ReserveReturned".equals(this.getReserveStatus()) )
    {
        ReserveReturned reserveReturned = new ReserveReturned();
        BeanUtils.copyProperties(this, reserveReturned);
        reserveReturned.publishAfterCommit();
        System.out.println("##### send event : ReserveReturned  #####");  
    }             
}

@PostRemove
public void onPostRemove(){

}

@PrePersist
public void onPrePersist(){
}

 3.2.3 예약/취소/반납 화면(html) 등록
   reservation/src/main/resources
     static 폴더생성
       reserve_action.html 파일 복사
       cancel_action.html 파일 복사
       return_action.html 파일 복사
 3.2.4 application.yml 수정
     external payment url 환경설정 추가

server: port: 8081 api: payment: url: http://localhost:8083

api: payment: url:${payment_url}

3.3 예약 서비스 실행
3.3.1 Terminal > new Terminal (1:cmd) 3.3.2 cd reservation 이동 3.3.3 서비스 실행 mvn spring-boot:run 3.3.4 서비스 기동 포트확인 cmd 1 번에서netstat -ano | findstr "PID :8081" 3.3.5 서비스 기본 CRUD command 동작 확인 cmd 5번에서 http http://localhost:8081/reservations === 사용안함http POST localhost:8081/reservations carId=“100” lentalAddr=“addr1” retriveAddr=“addr2” userPhone=“6401” amount=1000 => 등록 http http://localhost:8081/reservations/1 => 조회 === 사용안함http PATCH “http://localhost:8081/reservations/1” lentalAddr=“addr1111” => 수정 === 사용안함http DELETE “http://localhost:8081/reservations/1” => 삭제
3.3.6 서비스 종료 VS 터미널(1:cmd) 에서 Ctrl + C

4.결재서비스 구현 및 실행 4.1 서비스 포트 확인 payment/src/main/resource/application.yml spring > profiles : default port : 8083 4.2 결재 동기식(Req/Res) commnd Controller 방식 구현 payment/src/main/java/carsharing/PaymentController.java 수정 @RestController public class PaymentController { @Autowired PaymentRepository paymentRepository;

@RequestMapping(value = "/pay", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")

public boolean pay(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean ret = false;

            String reserveId = request.getParameter("reserveId").toString();
            String carId = request.getParameter("carId").toString();
            String amount = request.getParameter("amount").toString();
            String userPhone = request.getParameter("userPhone").toString();
            String payType = request.getParameter("payType").toString();
            String payNumber = request.getParameter("payNumber").toString();
            String payCompany = request.getParameter("payCompany").toString();

            System.out.println("##### /payment/pay  called #####");
            System.out.println("##### reserveId : " + reserveId);
            System.out.println("##### carId : " + carId);
            System.out.println("##### amount : " + amount);
            System.out.println("##### userPhone : " + userPhone);
            System.out.println("##### payType : " + payType);
            System.out.println("##### payNumber : " + payNumber);
            System.out.println("##### payCompany : " + payCompany);

            Payment payment = new Payment();
            payment.setReserveId(reserveId);
            payment.setCarId(carId);
            payment.setAmount(amount);
            payment.setUserPhone(userPhone);
            payment.setPayType(payType);
            payment.setPayNumber(payNumber);
            payment.setPayCompany(payCompany);
            payment.setPayStatus("Payed");

            payment  = paymentRepository.save(payment);

            if (payment != null) {
                    System.out.println("##### /payment/pay  save success #####");
                    ret = true;
            } else {
                    System.out.println("##### /payment/pay  save fail #####");
                    ret = false;
            }

            return ret;
    }

} 4.3 Policy 구현(이벤트 수신) payment/src/main/java/carsharing/PolicyHandler.java 수정

@Autowired PaymentRepository paymentRepository;

@StreamListener(KafkaProcessor.INPUT)
public void wheneverReserveCanceled_CancelPay(@Payload ReserveCanceled reserveCanceled){

    if(!reserveCanceled.validate()) return;

    System.out.println("\n\n##### listener CancelPay : " + reserveCanceled.toJson() + "\n\n");

    String reserveId = reserveCanceled.getId().toString();
    Payment payment = paymentRepository.findByReserveId(reserveId);
    if (payment != null) {
        payment.setPayStatus("PayCanled");
        LocalDate localDate = LocalDate.now();                
        payment.setPayCancelDate(localDate.toString());              
        paymentRepository.save(payment); 

        System.out.println("##### payment caused by reservation cancel #####");
        System.out.println("reserveId : " + reserveId);    
    }            
}

4.4 이벤트 송출 구현 payment/src/main/java/carsharing/Payment.java 수정 @PostUpdate public void onPostUpdate(){ if ("PayCanled".equals(this.getPayStatus())) { PayCanceled payCanceled = new PayCanceled(); BeanUtils.copyProperties(this, payCanceled); payCanceled.publishAfterCommit(); }
}

4.5 레파지터리 findByReserveId 함수구현 payment/src/main/java/carsharing/PaymentRepository.java Payment findByReserveId(String reserveId);

4.6 결재 서비스 실행 4.6.1 Terminal > new Terminal (2: cmd) 4.6.2 cd payement 이동 4.6.3 서비스 실행 mvn spring-boot:run 4.6.4 서비스 기동 포트 확인 cmd 1 번에서netstat -ano | findstr "PID :8083" -> 서비스 포트 기동 확인 4.6.5 서비스 기동 확인 cmd 5번에서 http http://localhost:8083/payments http http://localhost:8083/payments/1 => 조회 == 사용안함 http PATCH “http://localhost:8083/payments/1” amount="10001" == 사용안함 http DELETE “http://localhost:8083/payments/1” => 삭제

5.대여 구현 및 실행 5.1 서비스 포트 확인 rental/src/main/resource/application.yml spring > profiles : default port : 8082 5.2 command (차량대여, 차량반납) 구현 rental/src/main/java/carsharing/RentalController.java @RestController public class RentalController {

@RequestMapping(value = "/rentaled",
method = RequestMethod.POST,
produces = "application/json;charset=UTF-8")

public String rentaled(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /rentaled  called #####");

    String reserveId = request.getParameter("reserveId");
    String rentalDate = request.getParameter("rentalDate");        
    System.out.println("##### reserveId : " + reserveId);
    System.out.println("##### rentalDate : " + rentalDate);

    Optional<Rental> rentalOptional = RentalApplication.applicationContext.getBean(carsharing.RentalRepository.class)
              .findById(Long.parseLong(reserveId));

    String status = "Rentaled";                     
    if (rentalOptional.isEmpty() == false) {
        Rental rental = rentalOptional.get();
        String curStatus = rental.getRentalStatus();            
        if ("RentalAccepted".equals(curStatus)) {            
            rental.setRentalDate(rentalDate);
            rental.setRentalStatus(status);

            RentalApplication.applicationContext.getBean(carsharing.RentalRepository.class)
            .save(rental);
        }
        else {
            status = "reserve status is not RentalAccepted(current : " + curStatus + ")"; 
        }
    }   
    else{
        status = "not found reserveId : " + reserveId; 
    } 

    return status; 
}

@RequestMapping(value = "/retrieved",
method = RequestMethod.POST,
produces = "application/json;charset=UTF-8")

public String retrieved(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /retrieved  called #####");

    String reserveId = request.getParameter("reserveId");
    String retrieveDate = request.getParameter("retrieveDate");        
    System.out.println("##### reserveId : " + reserveId);
    System.out.println("##### retrieveDate : " + retrieveDate);

    Optional<Rental> rentalOptional = RentalApplication.applicationContext.getBean(carsharing.RentalRepository.class)
              .findById(Long.parseLong(reserveId));

    String status = "RentalRetrieved";                     
    if (rentalOptional.isEmpty() == false) {
        Rental rental = rentalOptional.get();
        String curStatus = rental.getRentalStatus();            
        if ("ReturnAccepted".equals(curStatus)) {              
            rental.setRentRetrieveDate(retrieveDate);
            rental.setRentalStatus(status);

            RentalApplication.applicationContext.getBean(carsharing.RentalRepository.class)
            .save(rental);
        }
        else {
            status = "reserve status is not ReturnAccepted(current : " + curStatus + ")"; 
        }            

    }   
    else{
        status = "not found reserveId : " + reserveId; 
    } 

    return status; 
}   

}

5.3 Policy 구현(이벤트 수신) rental/src/main/java/carsharing/PolicyHandler.java @Service public class PolicyHandler{ @Autowired RentalRepository rentalRepository;

@StreamListener(KafkaProcessor.INPUT)
public void wheneverReserved_AcceptRental(@Payload Reserved reserved){

    if(!reserved.validate()) return;

    System.out.println("\n\n##### listener AcceptRental : " + reserved.toJson() + "\n\n");

    String reserveId = Long.toString(reserved.getId());
    String carId = reserved.getCarId();
    String rentalAddr = reserved.getRentalAddr();
    String retrieveAddr = reserved.getRetrieveAddr();
    String userPhone = reserved.getUserPhone();
    Long amount = reserved.getAmount();
    String payType = reserved.getPayType();
    String payNumber = reserved.getPayNumber();
    String payCompany = reserved.getPayCompany();
    String reserveDate = reserved.getReserveDate();

    Rental rental = new Rental();
    rental.setReserveId(reserveId);
    rental.setCarId(carId);
    rental.setRentalAddr(rentalAddr);
    rental.setRetrieveAddr(retrieveAddr);
    rental.setUserPhone(userPhone);
    rental.setAmount(amount);
    rental.setPayType(payType);
    rental.setPayNumber(payNumber);
    rental.setPayCompany(payCompany);
    rental.setReserveDate(reserveDate);
    LocalDate localDate = LocalDate.now();                
    rental.setRentAcceptDate(localDate.toString());
    rental.setRentalStatus("RentalAccepted");
    rentalRepository.save(rental);           

    System.out.println("##### rental accepted by reservation reserve #####");
    System.out.println("reserveId : " + reserveId);             
}

@StreamListener(KafkaProcessor.INPUT)
public void wheneverReserveCanceled_CancelRental(@Payload ReserveCanceled reserveCanceled){

    if(!reserveCanceled.validate()) return;

    System.out.println("\n\n##### listener CancelRental : " + reserveCanceled.toJson() + "\n\n");

    String reserveId = reserveCanceled.getId().toString();
    Rental rental = rentalRepository.findByReserveId(reserveId);
    if (rental != null) {
        rental.setRentalStatus("RentalCanceled");
        LocalDate localDate = LocalDate.now();                
        rental.setRentCancelDate(localDate.toString());            
        rentalRepository.save(rental); 

        System.out.println("##### lental canceld by reservation cancel #####");
        System.out.println("reserveId : " + reserveId);    
    }
    else{
        System.out.println("not found reserveId : " + reserveId);    
    }                   
}

@StreamListener(KafkaProcessor.INPUT)
public void wheneverReserveReturned_AcceptReturn(@Payload ReserveReturned reserveReturned){

    if(!reserveReturned.validate()) return;

    System.out.println("\n\n##### listener AcceptReturn : " + reserveReturned.toJson() + "\n\n");

    String reserveId = reserveReturned.getId().toString();
    Rental rental = rentalRepository.findByReserveId(reserveId);
    if (rental != null) {
        rental.setRentalStatus("ReturnAccepted");
        LocalDate localDate = LocalDate.now();                
        rental.setRetAcceptDate(localDate.toString());            
        rentalRepository.save(rental); 

        System.out.println("##### return accepted by reservation return #####");
        System.out.println("reserveId : " + reserveId);    
    }             
    else{
        System.out.println("not found reserveId : " + reserveId);    
    }                   

}

@StreamListener(KafkaProcessor.INPUT)
public void whatever(@Payload String eventString){}

}

5.4 이벤트 송출 구현 rental/src/main/java/carsharing/Rental.java

@PostPersist
public void onPostPersist(){
    if ("RentalAccepted".equals(this.getRentalStatus())) {        
        RentalAccepted rentalAccepted = new RentalAccepted();
        BeanUtils.copyProperties(this, rentalAccepted);
        rentalAccepted.publishAfterCommit();
    }
}

@PostUpdate
public void onPostUpdate(){
    if ("Rentaled".equals(this.getRentalStatus())) {        
        Rentaled rentaled = new Rentaled();
        BeanUtils.copyProperties(this, rentaled);
        rentaled.publishAfterCommit();
    }
    else if ("RentalCanceled".equals(this.getRentalStatus())) {        
        RentalCanceled rentalCanceled = new RentalCanceled();
        BeanUtils.copyProperties(this, rentalCanceled);
        rentalCanceled.publishAfterCommit(); 
    }
    else if ("RentalRetrieved".equals(this.getRentalStatus())) {  
        RentalRetrieved rentalRetrieved = new RentalRetrieved();
        BeanUtils.copyProperties(this, rentalRetrieved);
        rentalRetrieved.publishAfterCommit();
    }
    else if ("ReturnAccepted".equals(this.getRentalStatus())) {  
        ReturnAccepted returnAccepted = new ReturnAccepted();
        BeanUtils.copyProperties(this, returnAccepted);
        returnAccepted.publishAfterCommit();
    }
}

5.5 레파지터리 findByReserveId 함수구현 rental/src/main/java/carsharing/RentalRepository.java Rental findByReserveId(String reserveId);

5.7 차량대여/차량회수 화면(html) 등록 rental/src/main/resources static 폴더생성 rental_action.html 파일 복사 retrieve_action.html 파일 복사 5.8 대여 서비스 실행 5.8.1 Terminal > new Terminal (3: cmd) 5.8.2 cd payement 이동 5.8.3 서비스 실행 mvn spring-boot:run 5.8.4 서비스 기동 포트 확인 cmd 1 번에서netstat -ano | findstr "PID :8082" -> 서비스 포트 기동 확인 5.8.5 서비스 기동 확인 cmd 5번에서 http http://localhost:8082/rentals http http://localhost:8082/rentals/1 => 조회 == 사용안함 http PATCH “http://localhost:8083/rentals/1” amount="10001" == 사용안함 http DELETE “http://localhost:8083/rentals/1” => 삭제

  1. 고객 구현 및 실행 6.1 서비스 포트 확인 customer/src/main/resource/application.yml spring > profiles : default port : 8084 6.2 MyPage 레파지터리 find 함수 동일함수 삭제 customer/src/main/java/carsharing/MyPageRepository.java List findByReserveId(String reserveId); List findByUserPhone(String userPhone); 6.3 MyPage 뷰 구현 customer/src/main/java/carsharing/MyPageViewHandler.java @Service public class MyPageViewHandler {

    @Autowired private MyPageRepository myPageRepository;

    @StreamListener(KafkaProcessor.INPUT) public void whenReserved_then_CREATE_1 (@Payload Reserved reserved) { try {

        if (!reserved.validate()) return;
    
        // view 객체 생성
        MyPage myPage = new MyPage();
        // view 객체에 이벤트의 Value 를 set 함
        myPage.setReserveId(reserved.getId().toString());
        myPage.setAmount(reserved.getAmount());
        myPage.setReserveDate(reserved.getReserveDate());
        myPage.setRentalAddr(reserved.getRentalAddr());
        myPage.setRetrieveAddr(reserved.getRetrieveAddr());
        myPage.setCarId(reserved.getCarId());
        myPage.setUserPhone(reserved.getUserPhone());
        myPage.setStatus("Reserved");
        // view 레파지 토리에 save
        myPageRepository.save(myPage);
    
    }catch (Exception e){
        e.printStackTrace();
    }

    }

    @StreamListener(KafkaProcessor.INPUT) public void whenRentalAccepted_then_UPDATE_1(@Payload RentalAccepted rentalAccepted) { try { if (!rentalAccepted.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(rentalAccepted.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setRentAcceptDate(rentalAccepted.getRentAcceptDate()); myPage.setStatus("RentalAccepted"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenRentaled_then_UPDATE_2(@Payload Rentaled rentaled) { try { if (!rentaled.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(rentaled.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setRentalDate(rentaled.getRentalDate()); myPage.setStatus("Rentaled"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenReserveCanceled_then_UPDATE_3(@Payload ReserveCanceled reserveCanceled) { try { if (!reserveCanceled.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(reserveCanceled.getId().toString()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setCancelDate(reserveCanceled.getCancelDate()); myPage.setStatus("ReserveCanceled"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenRentalCanceled_then_UPDATE_4(@Payload RentalCanceled rentalCanceled) { try { if (!rentalCanceled.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(rentalCanceled.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setRentCancelDate(rentalCanceled.getRentCancelDate()); myPage.setStatus("RentalCanceled"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenPayCanceled_then_UPDATE_5(@Payload PayCanceled payCanceled) { try { if (!payCanceled.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(payCanceled.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setPayCancelDate(payCanceled.getPayCancelDate()); myPage.setStatus("PayCanceled"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenReserveReturned_then_UPDATE_6(@Payload ReserveReturned reserveReturned) { try { if (!reserveReturned.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(reserveReturned.getId().toString()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setReturnDate(reserveReturned.getReturnDate()); myPage.setStatus("ReserveReturned"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenReturnAccepted_then_UPDATE_7(@Payload ReturnAccepted returnAccepted) { try { if (!returnAccepted.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(returnAccepted.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setRetAcceptDate(returnAccepted.getRetAcceptDate()); myPage.setStatus("ReturnAccepted"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } @StreamListener(KafkaProcessor.INPUT) public void whenRentalRetrieved_then_UPDATE_8(@Payload RentalRetrieved rentalRetrieved) { try { if (!rentalRetrieved.validate()) return; // view 객체 조회 List myPageList = myPageRepository.findByReserveId(rentalRetrieved.getReserveId()); for(MyPage myPage : myPageList){ // view 객체에 이벤트의 eventDirectValue 를 set 함 myPage.setRentRetrieveDate(rentalRetrieved.getRentRetrieveDate()); myPage.setStatus("RentalRetrieved"); // view 레파지 토리에 save myPageRepository.save(myPage); }

    }catch (Exception e){
        e.printStackTrace();
    }

    } }

    6.4 레파지터리 findByReserveId 함수구현 customer/src/main/java/carsharing/CustomerRepository.java Customer findByReserveId(String reserveId); 6.5 이벤트 수신 구현 customer/src/main/java/carsharing/PolicyHandler.java @Service public class PolicyHandler{ @Autowired CustomerRepository customerRepository;

    @StreamListener(KafkaProcessor.INPUT) public void wheneverPayCanceled_ChangeStatus(@Payload PayCanceled payCanceled){

    if(!payCanceled.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + payCanceled.toJson() + "\n\n");
    
    String reserveId = payCanceled.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("PayCanceled");
        customer.setPayCancelDate(payCanceled.getPayCancelDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### pay status changed by 'payCanceled' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverReserveReturned_ChangeStatus(@Payload ReserveReturned reserveReturned){

    if(!reserveReturned.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + reserveReturned.toJson() + "\n\n");
    
    String reserveId = reserveReturned.getId().toString();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("ReserveReturned");
        customer.setReturnDate(reserveReturned.getReturnDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### reserve status changed by 'reserveReturned' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    }  

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverReserved_ChangeStatus(@Payload Reserved reserved){

    if(!reserved.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + reserved.toJson() + "\n\n");
    
    String reserveId = Long.toString(reserved.getId());
    String carId = reserved.getCarId();
    String rentalAddr = reserved.getRentalAddr();
    String retrieveAddr = reserved.getRetrieveAddr();
    String userPhone = reserved.getUserPhone();
    Long amount = reserved.getAmount();
    String reserveDate = reserved.getReserveDate();
    
    Customer customer = new Customer();
    customer.setReserveId(reserveId);
    customer.setCarId(carId);
    customer.setRentalAddr(rentalAddr);
    customer.setRetrieveAddr(retrieveAddr);
    customer.setUserPhone(userPhone);
    customer.setAmount(amount);
    customer.setReserveDate(reserveDate);
    customer.setStatus("Reserved");
    customerRepository.save(customer);         
    
    System.out.println("##### customer saved by 'reserved' #####");
    System.out.println("reserveId : " + reserveId); 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverReserveCanceled_ChangeStatus(@Payload ReserveCanceled reserveCanceled){

    if(!reserveCanceled.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + reserveCanceled.toJson() + "\n\n");
    
    String reserveId = reserveCanceled.getId().toString();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("ReserveCanceled");
        customer.setCancelDate(reserveCanceled.getCancelDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### reserve status changed by 'reserveCanceled' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverRentalCanceled_ChangeStatus(@Payload RentalCanceled rentalCanceled){

    if(!rentalCanceled.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + rentalCanceled.toJson() + "\n\n");
    
    String reserveId = rentalCanceled.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("RentalCanceled");
        customer.setRentCancelDate(rentalCanceled.getRentCancelDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### rental status changed by 'rentalCanceled' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverRentalRetrieved_ChangeStatus(@Payload RentalRetrieved rentalRetrieved){

    if(!rentalRetrieved.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + rentalRetrieved.toJson() + "\n\n");
    
    String reserveId = rentalRetrieved.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("RentalRetrieved");
        customer.setRentRetrieveDate(rentalRetrieved.getRentRetrieveDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### rental status changed by 'rentalRetrieved' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverRentalAccepted_ChangeStatus(@Payload RentalAccepted rentalAccepted){

    if(!rentalAccepted.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + rentalAccepted.toJson() + "\n\n");
    
    String reserveId = rentalAccepted.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("RentalAccepted");
        customer.setRentAcceptDate(rentalAccepted.getRentAcceptDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### rental status changed by rental 'rentalAccepted' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    }

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverRentaled_ChangeStatus(@Payload Rentaled rentaled){

    if(!rentaled.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + rentaled.toJson() + "\n\n");
    
    String reserveId = rentaled.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("Rentaled");            
        customer.setRentalDate(rentaled.getRentalDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### rental status changed by 'rentaled'' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void wheneverReturnAccepted_ChangeStatus(@Payload ReturnAccepted returnAccepted){

    if(!returnAccepted.validate()) return;
    
    System.out.println("\n\n##### listener ChangeStatus : " + returnAccepted.toJson() + "\n\n");
    
    String reserveId = returnAccepted.getReserveId();
    Customer customer = customerRepository.findByReserveId(reserveId);
    if (customer != null) {
        customer.setStatus("ReturnAccepted");             
        customer.setRetAcceptDate(returnAccepted.getRetAcceptDate());            
        customerRepository.save(customer); 
    
        System.out.println("##### rental status changed by 'returnAccepted' #####");
        System.out.println("reserveId : " + reserveId); 
    }          
    else{
        System.out.println("not found reserveId : " + reserveId);    
    } 

    } @StreamListener(KafkaProcessor.INPUT) public void whatever(@Payload String eventString){}

}

6.6 이벤트송출 구현 customer/src/main/java/carsharing/Customer.java @PostPersist public void onPostPersist(){ StateChanged stateChanged = new StateChanged(); BeanUtils.copyProperties(this, stateChanged); stateChanged.publishAfterCommit(); }

@PostUpdate
public void onPostUpdate(){
    StateChanged stateChanged = new StateChanged();
    BeanUtils.copyProperties(this, stateChanged);
    stateChanged.publishAfterCommit();
}

6.7 mypage 조회 Controller 구현 customer/src/main/java/carsharing/CustomerController.java

@RestController public class CustomerController { @Autowired private MyPageRepository myPageRepository;

@RequestMapping(value = "/mypage",
method = RequestMethod.GET,
produces = "application/json;charset=UTF-8")

public void mypage(HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("##### /myPage  called #####");

    String reserveId = request.getParameter("reserveId").toString();
    String userPhone = request.getParameter("userPhone").toString();

    List<MyPage> myPageList = null;
    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");
    PrintWriter writer = response.getWriter();

    if (reserveId != "") {
        myPageList = myPageRepository.findByReserveId(reserveId);
    }
    else {
        myPageList = myPageRepository.findByUserPhone(userPhone);
    }

    if (myPageList.size() > 0) {

        for(int i = 0; i < myPageList.size(); i++) {
            MyPage myPage = myPageList.get(i);

            reserveId = myPage.getReserveId();
            userPhone = myPage.getUserPhone();
            String statsus = myPage.getStatus();
            String carId = myPage.getCarId();
            String rentalAddr = myPage.getRentalAddr();
            String retrieveAddr = myPage.getRetrieveAddr();
            Long amount = myPage.getAmount();
            String reserveDate = myPage.getReserveDate();
            String cancelDate = myPage.getCancelDate();
            String returnDate = myPage.getReturnDate();
            String rentalDate = myPage.getRentalDate();
            String rentAcceptDate = myPage.getRentAcceptDate();
            String rentCancelDate = myPage.getRentCancelDate();
            String retAcceptDate = myPage.getRetAcceptDate();
            String retRetrieveDate = myPage.getRentRetrieveDate();
            String payCancelDate = myPage.getPayCancelDate();

            writer.write(i + " : ");
            writer.write("reserveId=" + reserveId);
            writer.write(",userPhone=" + userPhone);
            writer.write(",status=" + statsus);
            writer.write(",carId=" + carId);
            writer.write(",rentalAddr=" + rentalAddr);
            writer.write(",retrieveAddr=" + retrieveAddr);
            writer.write(",amount=" + amount);
            writer.write(",reserveDate=" + reserveDate);
            if (returnDate != null) {
                writer.write(",returnDate=" + returnDate);
            }
            if (cancelDate != null) {
                writer.write(",cancelDate=" + cancelDate);
            }
            if (rentAcceptDate != null) {
                writer.write(",rentAcceptDate=" + rentAcceptDate);
            }
            if (rentalDate != null) {
                writer.write(",rentalDate=" + rentalDate );
            }
            if (retAcceptDate != null) {
                writer.write(",retAcceptDate=" + retAcceptDate);
            }
            if (retRetrieveDate != null) {
                writer.write(",retRetrieveDate=" + retRetrieveDate);
            }
            if (rentCancelDate != null) {
                writer.write(",rentCancelDate=" + rentCancelDate);
            }
            if (payCancelDate != null) {
                writer.write(",payCancelDate=" + payCancelDate);
            }
            writer.write("\r\n");
        }
    }   
    else{
        if (reserveId != "") {
            writer.write("not found reserveId : " + reserveId + "\r\n");
        }
        else {
            writer.write("not found userPhone : " + userPhone + "\r\n");
        }            
    } 

    writer.flush();
    writer.close();        
}    

6.8 mypage 화면(html) 등록 customer/src/main/resources static 폴더생성 mypage_action.html 파일 복사 6.9 고객 서비스 실행 6.9.1 Terminal > new Terminal (4: cmd) 6.9.2 cd payement 이동 6.9.3 서비스 실행 mvn spring-boot:run 6.9.4 서비스 기동 포트 확인 cmd 1 번에서netstat -ano | findstr "PID :8084" -> 서비스 포트 기동 확인 6.9.5 서비스 기동 확인 cmd 5번에서 http http://localhost:8084/customers http http://localhost:8084/myPages

  1. 게이트웨이(프런트 통합채널 포트) 설정 및 실행 7.1 게이트웨이 통합채널 포트 확인 및 predicates url 추가 : gateway/src/main/resource/application.yml server: port: 8088 # 게이트웨이 포트 확인

spring: profiles: default cloud: gateway: routes:

spring: profiles: docker cloud: gateway: routes:

8.전체 시나리오 확인 8.1 예약 8.1.1 브라우저 http://localhost:8088/reserve_action.html (게이트웨이 포트사용) 또는 http://localhost:8081/reserve_action.html 실행 8.1.2 예약 화면에서 항목 입력 후 <예약> 버튼 클릭 8.1.3 예약 등록 화인 cmd 5번에서 http http://localhost:8081/reservations http http://localhost:8083/payments http http://localhost:8082/rentals http http://localhost:8084/customers http http://localhost:8084/myPages 8.1.4 예약이벤트 발생 화인 cmd 4번에서 Reserved 이벤트 확인 RentalAccepted 이벤트 확인 StateChanged 이벤트2번 확인(status :Reserved, RentalAccepted) kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning => 기 기동되어 있어야 함. 8.1.5 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(게이트웨이 포트사용) 또는 http://localhost:8084/mypage_action.html 실행 예약번호 넣고 조회 status : RentalAccepted 상태 확인

8.2 차량대여 8.2.1 브라우저 http://localhost:8088/lental_action.html(게이트웨이 포트사용) 또는 http://localhost:8082/lental_action.html 실행 8.2.2 차량대여 화면에서 에약번호/대여일자 입력 후 <차량대여> 버튼 클릭 8.2.3 차랭대여 화인 cmd 5번에서 http http://localhost:8082/rentals => rentalDate 날짜확인 8.2.4 예약이벤트 발생 화인
cmd 4번에서 Rentaled 이벤트 확인 StateChanged 이벤트 확인(status :Rentaled) kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning => 기 기동되어 있어야 함. 8.2.5 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(게이트웨이 포트사용) 또는 http://localhost:8084/mypage_action.html 실행 예약번호 넣고 조회 status : Rentaled 상태 확인 8.3 예약 반납 8.3.1 브라우저 http://localhost:8088/return_action.html(게이트웨이 포트사용) 또는 http://localhost:8081/return_action.html 실행 8.3.2 예약반납 화면에서 예약번호/반납일자 입력 후 <예약반납> 버튼 클릭 8.3.3 예약반납 상태 화인 cmd 5번에서 http http://localhost:8081/reservations => reserveSatus : ReserveReturned http http://localhost:8082/rentals => lentalSatus : ReturnAccepted, retAcceptDate 날짜 확인 8.3.4 예약이벤트 발생 화인
cmd 4번에서 ReserveReturned 이벤트 확인 ReturnAccepted 이벤트 확인 StateChanged 이벤트2번 확인(status :ReserveReturned, ReturnAccepted) kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning => 기 기동되어 있어야 함. 8.3.5 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(케이트웨이포트 사용) 또는 http://localhost:8084/mypage_action.html 실행 예약번호 넣고 조회 status : ReturnAccepted 상태 확인 8.4 차량 회수 8.4.1 브라우저 http://localhost:8088/retrieve_action.html (게이트웨이 포트사용), 또는 http://localhost:8082/retrieve_action.html 실행 8.4.2 차량회수 화면에서 예약번호/회수일자 입력 후 <차량회수> 버튼 클릭 8.4.3 차량회수 상태 화인 cmd 5번에서 http http://localhost:8082/rentals => lentalSatus : RentalRetrieved, retrieveDate 날짜 확인 8.4.4 예약이벤트 발생 화인
cmd 4번에서 RentalRetrieved 이벤트 확인 StateChanged 이벤트2번 확인(status :RentalRetrieved) kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning => 기 기동되어 있어야 함. 8.4.5 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(케이트웨이포트 사용) 또는 http://localhost:8084/mypage_action.html 실행 예약번호 넣고 조회 status : RentalRetrieved 상태 확인 8.5 예약 취소 8.5.1 위 예약 후 8.5.2 브라우저 http://localhost:8081/cancel_action.html 실행 8.5.3 예약취소 화면에서 에약번호/취소일자 입력 후 <예약취소> 버튼 클릭 8.5.4 예약취소 상태 화인 cmd 5번에서 http http://localhost:8081/reservations => reserveSatus : ReserveCanceled http http://localhost:8083/payments => paySatus : PayCanceled http http://localhost:8082/rentals => lentalSatus : RentalCanceled, retCancelDate 8.5.5 예약이벤트 발생 화인 cmd 4번에서 ReserveCanceled 이벤트 확인 payCanceled 이벤트 확인 RentalCanceled 이벤트 확인 StateChanged 이벤트3번 확인(status :ReserveCanceled, payCanceled, RentalCanceled) kafka-console-consumer.bat --bootstrap-server http://localhost:9092 --topic carsharing --from-beginning => 기 기동되어 있어야 함. 8.5.5 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(케이트웨이포트 사용) 또는 http://localhost:8084/mypage_action.html 실행 예약번호 넣고 조회 status : RentalCanceled 상태 확인 8.6 mypage 확인 8.6.1 에약 (핸드폰 동일하게 입력) 8.6.2 mypage 확인 브라우저 http://localhost:8088/mypage_action.html(케이트웨이포트 사용) 또는 http://localhost:8084/mypage_action.html 실행 핸드폰 번호 넣고 조회 2건 에약 내역 조회 확인

8.7 결재서비스 중지시 예약 진행 안됨(동기식호출) 8.7.1 결재서비스 종료 결재 서비스 기동 Terminal 에서 Ctrl + C > Y 종료 8.7.2 위 에약 실행 .브라우저 결과 화면에서 ReserveFailed 확인 .이벤트 창에서 이벤트 발생 안함 확인 cmd 5번에서 http http://localhost:8081/reservations => 해당 예약번호 reserveStatus : ReserveFailed

cej55 commented 3 years ago

참고로 모델과 소스 구조를 나름 정리해 봤습니다. image