File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
matching-application/app-api/src/main/kotlin/com/grepp/quizy/matching/api/sse
matching-infra/src/main/kotlin/com/grepp/quizy/matching/infra/match/pubsub Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import com.grepp.quizy.matching.domain.match.MatchingEventSender
55import com.grepp.quizy.matching.domain.match.MatchingPoolManager
66import com.grepp.quizy.matching.domain.match.PersonalMatchingSucceedEvent
77import com.grepp.quizy.matching.domain.user.UserId
8+ import io.github.oshai.kotlinlogging.KotlinLogging
89import org.springframework.stereotype.Component
910import org.springframework.web.servlet.mvc.method.annotation.SseEmitter
1011import java.io.IOException
@@ -16,6 +17,8 @@ class SseSender(
1617 private val objectMapper : ObjectMapper
1718) : MatchingEventSender {
1819
20+ private val log = KotlinLogging .logger {}
21+
1922 override fun send (event : PersonalMatchingSucceedEvent ) {
2023 val emitter = emitterRepository.findById(event.userId) ? : return
2124
@@ -26,11 +29,12 @@ class SseSender(
2629 .name(" MATCHING" )
2730 .data(objectMapper.writeValueAsString(MatchingSucceed (event.gameRoomId)))
2831 )
29- emitter.complete()
32+ log.info { " SSE event sent to ${event.userId} " }
3033 closeEmitter(event.userId)
34+ emitter.complete()
3135 } catch (e: IOException ) {
3236 closeEmitter(event.userId)
33- emitter.completeWithError(e )
37+ emitter.complete( )
3438 }
3539 }
3640
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.grepp.quizy.matching.infra.match.pubsub
33import com.fasterxml.jackson.databind.ObjectMapper
44import com.grepp.quizy.matching.domain.match.MatchingEventSender
55import com.grepp.quizy.matching.domain.match.PersonalMatchingSucceedEvent
6+ import io.github.oshai.kotlinlogging.KotlinLogging
67import org.springframework.data.redis.connection.Message
78import org.springframework.data.redis.connection.MessageListener
89import org.springframework.stereotype.Component
@@ -13,15 +14,19 @@ class MatchingRedisSubscriber(
1314 private val objectMapper : ObjectMapper ,
1415) : MessageListener {
1516
17+ private val log = KotlinLogging .logger {}
18+
1619 override fun onMessage (message : Message , pattern : ByteArray? ) {
1720 try {
1821 val event = objectMapper.readValue(
1922 message.body,
2023 PersonalMatchingSucceedEvent ::class .java
2124 )
2225
26+ log.info { " Matching succeeded event: $event " }
2327 matchingEventSender.send(event)
2428 } catch (e: Exception ) {
29+ log.error(e) { " Matching failed" }
2530 throw IllegalArgumentException (" Failed to send event to Redis" , e.cause)
2631 }
2732 }
You can’t perform that action at this time.
0 commit comments