-
Notifications
You must be signed in to change notification settings - Fork 3
FCM 메시지를 받을 유저 필터링 로직 구현 #220
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
Conversation
- userActive value는 object - onlineSession value는 String - 이 차이로 인해 Redis removeAll 적용 X - userActive value에 따옴표를 붙여 해결
✅ Deploy Preview for jootalkpia canceled.
|
bo-ram-bo-ram
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
| JsonNode rootNode = mapper.readTree(kafkaMessage); | ||
| JsonNode commonNode = rootNode.get("common"); | ||
| JsonNode messagesNode = rootNode.get("message"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatMessageToKafka.getCommon()
chatMessageToKafka.getMessage()
로는 안될까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분에 대해선 FCM 발송 로직 구현 때 테스트 해보겠습니다!
| if (userActiveSessions != null) { | ||
| Set<String> sessions = convertToSet(userActiveSessions); | ||
| sessions.forEach(session -> | ||
| activeSessions.add("\"" + session + "\"")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redis가 string인데 해당처럼 변환을 해줘야할까요?
activeSessions.add(session);
이렇게도 가능하지않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Redis 저장 시 데이터 타입 불일치로 인한 removeAll 연산 실패
- userActive: Object 타입으로 저장됨 (Redis hash value)
- onlineSession: String 타입으로 저장됨 (Redis set value)
따라서 두 값의 형식 차이로 인해 Set.removeAll() 연산이 정상 동작하지 않았기 때문에 변환을 했습니다!
보람님 방식으로 처음에 구현했으나 필터링이 되지 않아 변경했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아 이해했습니다! 피알 내용이 이부분인지 이해를 못했었네요 고생하셨어요!
| implementation 'org.springframework.boot:spring-boot-starter-data-redis' | ||
| implementation 'org.springframework.boot:spring-boot-starter-web' | ||
| implementation 'org.springframework.kafka:spring-kafka' | ||
| implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래에서 mapper를 사용하시던데 그렇다면 gson을 사용하시는 부분 있으신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kafka Producer에서 사용하고 있습니다!
Claude가 objectMapper와의 차이점을 다음과 같이 알려줬습니다!
ObjectMapper가 더 빠른 성능을 보이고 다양한 기능을 제공하는 반면, Gson은 더 간단하고 직관적인 사용법이 특징입니다.
Gson의 가장 큰 장점은 사용하기 쉽고 학습 곡선이 낮다는 점입니다. 단일 jar 파일로 제공되어 의존성 관리가 쉽고, null 값 처리도 자동으로 해주어 별도 설정이 필요 없습니다. 또한 라이브러리 크기가 작아 전체 애플리케이션 크기를 줄일 수 있습니다.
결국 선택은 프로젝트의 요구사항에 따라 달라집니다. 간단한 JSON 처리와 빠른 개발이 중요하다면 Gson을, 고성능과 세밀한 제어가 필요하다면 ObjectMapper를 사용하는 것이 좋습니다.
Kafka Produce 시에는 Json 데이터를 단순히 String으로 변환만 하기 때문에 gson도 괜찮아 보여서 계속 사용하고 있었습니다!
Pull request
Related issue
Motivation and context
removeAll연산 실패userActive: Object 타입으로 저장됨 (Redis hash value)onlineSession: String 타입으로 저장됨 (Redis set value)Set.removeAll()연산이 정상 동작하지 않음findActiveSessions()에서 반환하는 세션 ID에 따옴표를 추가하여onlineSession과 동일한 형식으로 통일Set.removeAll()연산이 정상적으로 수행됨KafkaConsumerclass 내 FCM 발송 로직 추가 필요Solution
How has this been tested
Types of changes
Checklist