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

[#37] 경매 상품 실시간 가격 변동 처리 #43

Merged
merged 3 commits into from
Nov 20, 2024
Merged

Conversation

JIWON27
Copy link
Collaborator

@JIWON27 JIWON27 commented Nov 9, 2024

경매 상품 최고가 변경시 이벤트 발생 및 SSE 알림

  • Kafka와 SSE를 사용해여 경매 상품들의 최고가 변경시 UI 변경을 위한 이벤트 발행 코드 추가

@JIWON27 JIWON27 requested a review from f-lab-moony November 9, 2024 13:41
@JIWON27 JIWON27 self-assigned this Nov 9, 2024
@JIWON27 JIWON27 linked an issue Nov 9, 2024 that may be closed by this pull request
Copy link
Collaborator

@f-lab-moony f-lab-moony left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다 ~
피드백 확인 부탁드려요!

@@ -22,7 +22,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.formLogin(AbstractHttpConfigurer::disable);

http.authorizeHttpRequests(authorize -> authorize
.requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() // 관리자만
.requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/auction/kafkaEvent/subscribe")).permitAll()
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거 근데 kafkaEvent라는건 알려줄 필요 없는 정보같아요 ~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 알겠습니다!!
삭제하도록 하겠습니당

import java.util.concurrent.ConcurrentHashMap;

@Repository
public class KafkaEmitterRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거때문에 모듈이 하나 분리되어있는 것 같은데 맞나요 ?
근데 이거 워커에서만 갖고 있으면 되는거 아닌가요 이제 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 워커 모듈로 가져오도록 하겠습니다!

try {
emitter.send(SseEmitter.event()
.id(emitterId)
.name("경매 상품 최고가 변경")
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거 이벤트 발행은 다른 기능에서도 쓸 수 있으니 name도 받게 해주는게 어떨까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵! name도 받을 수 있도록 하겠습니다

import java.io.IOException;

@Service
public class KafkaEmitterService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 Kafka가 붙을 필요가 없을 것 같아요 ~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 알겠습니다!

try {
ObjectMapper objectMapper = new ObjectMapper();
AuctionPriceChangeNotification notification = objectMapper.readValue(message, AuctionPriceChangeNotification.class);
SseEmitter adminEmitter = kafkaEmitterService.getAdminEmitter();
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 어차피 서비스 내에서 만들 수 있는거면 굳이 여기서 안만들어줘도 되지 않나요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

여러 방법 중 ObjectMapper를 사용해서 역직렬화한 것인데 ObjectMapper 사용안하도록 한번 해보겠습니다!

Copy link

Copy link
Collaborator

@f-lab-moony f-lab-moony left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다!
요건 더 볼건 없을거같아서 머지 하도록 할게요 ~

@f-lab-moony f-lab-moony merged commit 6afdad2 into main Nov 20, 2024
2 checks passed
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