Skip to content

[3주차] 예약 API 구현 및 Redisson Lock 구현#70

Open
jmParkGit wants to merge 5 commits intohanghae-skillup:jmParkGitfrom
jmParkGit:main
Open

[3주차] 예약 API 구현 및 Redisson Lock 구현#70
jmParkGit wants to merge 5 commits intohanghae-skillup:jmParkGitfrom
jmParkGit:main

Conversation

@jmParkGit
Copy link

[3주차] 예약 API 구현 및 Redisson Lock 사용

작업 내용

  • 2주차에 생성한 API(/api/movies) Refactoring
  • 3주차 티켓예매 API 생성 (PUT:: /api/ticketing/{id})
  • Redisson Lock을 티켓예매 API에 생성

발생했던 문제와 해결 과정을 남겨 주세요.

  • 일정 관계상 Lock 테스트를 진행 못함. 추후 진행예정

이번 주차에서 고민되었던 지점이나, 어려웠던 점을 알려 주세요.

과제를 해결하며 특히 어려웠던 점이나 고민되었던 지점이 있다면 남겨주세요.

리뷰 포인트

기타 질문

Copy link

@youngxpepp youngxpepp left a comment

Choose a reason for hiding this comment

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

안녕하세요 재민님. 이건홍 코치라고 합니다ㅎㅎ
과제하느라 고생하셨고 코드 리뷰 보면서 궁금하신 점 있다면 코멘트 남겨주세요.
감사합니다!

좋았던 점

  • redisson의 tryLock 잠금을 통해 영화 예매에 대한 데이터 무결성을 지켰습니다.

아쉬운 점

  • 잠금을 잘 구현해주셨는데 이에 대한 테스트가 없어서 아쉽네요ㅠㅠ 꼭 코드를 실행해보셨으면 좋겠습니다.
  • 요구사항 중에 FCM으로 메시지 발송을 하는 내용이 있는데 이 부분이 없어서 아쉽네요! 요구사항이 몇 개 더 있는데,, 3주차 시나리오에 맞춰서 구현을 하셨다면 어땠을까요! 아쉽습니다!!

Comment on lines +49 to +55
Movie movie = movieRepository.findById(id).orElseThrow(
() -> new NullPointerException("There is no id at DB.")
);

if(movie==null) {
return movie;
}

Choose a reason for hiding this comment

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

Suggested change
Movie movie = movieRepository.findById(id).orElseThrow(
() -> new NullPointerException("There is no id at DB.")
);
if(movie==null) {
return movie;
}
Movie movie = movieRepository.findById(id).orElseThrow(
() -> new NullPointerException("There is no id at DB.")
);

movie에 대해 orElseThrow를 하셨다면 movie가 null일 수는 없겠네요!
if 조건문은 없어도 되지 않을까요?ㅎㅎ

Comment on lines +60 to +63
if (!acquireLock) {
System.out.println("Lock get fail");
return movie;
}

Choose a reason for hiding this comment

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

예약이 실패됐다 라는 내용이 사용자에게 전달되려면 어떻게 해야 할까요?

Comment on lines +52 to +53
@Column
private Boolean[] seats = new Boolean[MAX_SEATS];

Choose a reason for hiding this comment

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

혹시 이 부분 테스트 해보셨을까요?
boolean 배열이 디비에 저장되기 위해선 적절한 변환 과정이 선언되어야 할듯 합니다.

return movie;
}

RLock lock = redissonClient.getLock(id.toString());

Choose a reason for hiding this comment

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

영화 전체에 대한 잠금이 걸려있네요!
영화 - 상영관 - 좌석 (5x5)
좌석은 상영관 별로 25개씩 있고, 상영관은 여러개 존재할 수 있어요.
잠금을 여러 개로 나눈다면 사용자가 덜 기다릴 수도 있지 않을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants