Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#54] 카프카를 통한 이벤트 기반 통신 구현 #57

Merged
merged 11 commits into from
Jul 27, 2024
Merged

Conversation

hyeok-kong
Copy link
Collaborator

개발 내용

  • 카프카 연동, payment-service 와 통신
  • 이벤트 기반의 결제 요청 -> 결제 완료 -> 그룹 인원 증가 흐름 구현

개발 코멘트

  • DTO 등과 같이 여러 마이크로서비스에서 재사용되는 클래스를 common-library 로 추출해야 합니다.
  • 이벤트가 세부적인 동작을 나타내며, 이에 강한 결합도가 생기는 것 같습니다. 토픽 크기, 처리 방식 변경 등 추가적인 고민이 필요합니다.

@hyeok-kong hyeok-kong added the enhancement New feature or request label Jul 27, 2024
@hyeok-kong hyeok-kong self-assigned this Jul 27, 2024

public class EventConstants {

public static final String GROUP_MEMBER_INCREASE_REQUEST = "dev.group.payment.request.increase-group-size";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

상수를 통해 카프카 토픽을 관리함으로써 human error 를 방지합니다.

*/
@Modifying
@Query("update Group g set g.groupSize = :groupSize where g.id = :id")
void updateGroupSize(@Param("id") Long id, @Param("groupSize") Integer groupSize);
Copy link
Collaborator Author

@hyeok-kong hyeok-kong Jul 27, 2024

Choose a reason for hiding this comment

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

해당 메소드는 동시성 문제 발생 가능성이 있습니다.
update 기능은 JPADirty Checking 을 통해서도 구현 가능하지만, entity에서 해당 기능을 호출할 수 있으므로 실수를 범할 가능성이 크다고 생각했습니다.

이에 동시성 문제가 발생할 수 있는 commandRepository 로 분리하는 방법을 사용해보았습니다.

@hyeok-kong
Copy link
Collaborator Author

두 마이크로서비스에서 공통적으로 사용되는 로직들이 다수 존재합니다.
다음 PR에서 공통 라이브러리로 추출하는 작업을 진행할 예정입니다.

@hyeok-kong hyeok-kong merged commit d6350aa into main Jul 27, 2024
1 check passed
@hyeok-kong hyeok-kong linked an issue Jul 27, 2024 that may be closed by this pull request
@hyeok-kong hyeok-kong deleted the feature/54 branch July 27, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

결제 서비스 구현
1 participant