Skip to content

Conversation

@yyy96
Copy link

@yyy96 yyy96 commented Mar 22, 2023

📝 구현

  • 동시성 문제를 해결하기 위한 여러가지 방법들을 각기 한번씩 구현하고 실행해보고자 하였습니다.
  • 다만, 로직을 구현하다보니 order 서비스보단 facade에서 해당 부분들을 변경하는 것이 맞는지 조금 혼동되었습니다.
  • 비즈니스 로직이나 객체지향적 설계등을 끝까지 다 구현하지 못했습니다🥲
  • 추후에 다른 동시성 해결 방법들을 좀 더 학습하며 완성하지 못한 부분들을 고도화 시켜나가겠습니다!

🚨 이슈사항 (해결)

  • Ticket 이 감소된 후 변경 감지가 일어나지 않아 테스트시 실패하고 있습니다..
    디버깅으로 확인해보면 Order에는 감소된 Ticket 수량이 들어가있지만, 실제 Ticket을 다시 호출하면 수량이 전혀 감소되어있지 않습니다
    해당 부분 이유를 알려주신다면 감사드리겠습니다 🙏🏻

🚨 이슈사항 (Update)

  • 영속성 컨텍스트, 트랜잭션에 따른 로직 / 테스트 변경 감지 문제를 해결하였습니다!
  • 하지만, 해당 문제를 해결하고 티켓이 감소되기 시작하니 데드락 문제가 발생하였습니다 😅
    해당 이슈 해결하여 고도화 진행 전 먼저 푸쉬하도록 하겠습니다.

@yyy96 yyy96 requested review from JoeCP17, Rayoungji and minsoozz March 22, 2023 16:11
Copy link
Contributor

@minsoozz minsoozz left a comment

Choose a reason for hiding this comment

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

연재님 고생 많으셨습니다!


import lombok.RequiredArgsConstructor;

@Component
Copy link
Contributor

Choose a reason for hiding this comment

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

@Component@Service 어노테이션의 차이를 나누는 기준이 어떻게 되는지 궁굼합니다~

Copy link
Author

@yyy96 yyy96 Mar 24, 2023

Choose a reason for hiding this comment

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

Facade 를 입사 후 처음 접하며 해당 부분에 대해서 @Component@Service 중 어느 것이 적합한지에 대해 좀 더 고민해보지 못했었던 것 같습니다..!

@Component@Service 둘 다 클래스를 컴포넌트로 등록하고 스프링 컨테이너에서 관리할 수 있도록 해주지만,
이때 @Service의 경우 좀더 세부적인 유스케이스 들을 위하여 @Component 의 구체화된 형태로서, 해당 클래스가 비즈니스 로직을 처리하는 서비스 역할을 한다는 것을 나타내주며 AOP에서 특정 작업을 수행하기 위해 다른 어노테이션과 결합하여 사용될 수도 있다는 것을 다시 한번 상기하였습니다.

처음 Facade 에 어노테이션을 붙일 때 메인 Service가 아니니 명시적인 의미로도 @Service 보단 @Component 가 적합하지 않을까? 하고 고민하였었는데요, 제 로직을 다시 보니 비즈니스?적인 로직들이 들어가있고, 해당 부분을 바탕으로 테스트를 진행한다는 점을 보면 @Service가 더 적합하려나..? 하는 생각이 드는 것도 같습니다..!

혹시 다른 좋은 기술적 의견이나 생각이 있으시다면 알려주시면 감사하겠습니다..!

Copy link
Contributor

Choose a reason for hiding this comment

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

@Service 도 결국 @Component 를 상속받고 있어서 기술적인 차이는 없다고 생각해요.
단지 비즈니스 로직에 대한 구분 역할을 해준다고 생각합니다.

코드에 고민을 많이 하신 흔적이 보여서 연재님은 어떻게 생각하시는지 의견을 여쭈고자 질문드렸습니다!
지금 생각해보면 Facade 계층이라는 것을 직관적으로 알 수 있는 @FacadeService 같은 커스텀 어노테이션을 사용해서 직관적으로 개선 할 수도 있을 것 같아요 👍

Copy link
Author

Choose a reason for hiding this comment

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

좋은 말씀과 의견 감사합니다! 추후 리팩토링에 반영하도록 하겠습니다!!😊

Copy link
Contributor

@minsoozz minsoozz left a comment

Choose a reason for hiding this comment

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

여러가지 동시성 제어 기법에 대해 테스트를 열심히 작성하셨네요~!
코드를 이해하는데 많은 도움이 되었습니다!


private final TicketRepository ticketRepository;

private final TicketQueryDslRepository ticketQueryDslRepository;
Copy link
Contributor

Choose a reason for hiding this comment

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

public interface TicketRepository extends JpaRepository<Ticket, Long>, CustomTicketRepository   {
}
public interface CustomTicketRepository {

}   
@Repository
public class TicketQueryDslRepository implements CustomTicketRepository {
}

해당 방법처럼 기본 레포지토리를 확장하는 방법도 있습니다 👍

Copy link
Author

@yyy96 yyy96 Mar 24, 2023

Choose a reason for hiding this comment

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

오 안그래도 저번 줌근마켓에서 해당 사항으로 구현하고 리뷰해보며 궁금한 점이 있었습니다..!

혹시 민수님께서는 어떤 방법이 더 적합하다고 생각하시는지 의견을 여쭤보고 배우고 싶습니다..!🙏🏻


import lombok.RequiredArgsConstructor;

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

주석을 꼼꼼하게 작성해주셨네요 👍

private UserLogin userLogin;

@Embedded
private Orders orders;
Copy link
Contributor

Choose a reason for hiding this comment

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

일급 컬렉션을 활용해서 Entity를 잘 설계하신 것 같습니다!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants