Skip to content

Commit 71f1556

Browse files
committed
refactor: SlackDeadLetterMessageListener가 처리중 에러가 발생 할 경우, 로그를 남기도록 수정한다
1 parent 21e3c28 commit 71f1556

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/main/kotlin/org/gitanimals/notification/app/SlackDeadLetterMessageListener.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.gitanimals.notification.app.event.DeadLetterEvent
66
import org.gitanimals.notification.domain.Notification
77
import org.gitanimals.notification.domain.Notification.ActionRequest
88
import org.gitanimals.notification.domain.Notification.ActionRequest.Style.PRIMARY
9+
import org.slf4j.LoggerFactory
910
import org.springframework.beans.factory.annotation.Qualifier
1011
import org.springframework.beans.factory.annotation.Value
1112
import org.springframework.data.redis.connection.Message
@@ -18,7 +19,9 @@ class SlackDeadLetterMessageListener(
1819
private val objectMapper: ObjectMapper,
1920
@Qualifier("gitAnimalsDeadLetterSlackNotification") private val notification: Notification,
2021
@Value("\${relay.approve.token}") private val approveToken: String,
21-
): TraceableMessageListener(redisTemplate, objectMapper) {
22+
) : TraceableMessageListener(redisTemplate, objectMapper) {
23+
24+
private val logger = LoggerFactory.getLogger(this::class.simpleName)
2225

2326
override fun onMessage(message: Message) {
2427
runCatching {
@@ -51,6 +54,8 @@ class SlackDeadLetterMessageListener(
5154
)
5255
),
5356
)
57+
}.onFailure {
58+
logger.error("Fail to notify dead letter. message: $message", it)
5459
}
5560
}
5661
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package org.gitanimals.notification.app.event
22

3-
import org.rooftop.netx.api.SagaEvent
4-
53
data class DeadLetterEvent(
64
val traceId: String,
75
val deadLetterId: String,
8-
val sagaEvent: SagaEvent,
6+
val sagaId: String,
7+
val nodeName: String,
8+
val group: String,
9+
val deadLetter: String,
910
)

src/main/kotlin/org/gitanimals/supports/deadletter/DeadLetterEvent.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import org.gitanimals.core.IdGenerator
44
import org.gitanimals.core.filter.MDCFilter
55
import org.gitanimals.core.redis.AsyncRedisPubSubEvent
66
import org.gitanimals.core.redis.RedisPubSubChannel.DEAD_LETTER_OCCURRED
7-
import org.rooftop.netx.api.SagaEvent
87
import org.slf4j.MDC
98

109
data class DeadLetterEvent(
11-
private val deadLetterId: String,
12-
private val sagaEvent: SagaEvent
13-
): AsyncRedisPubSubEvent(
10+
val deadLetterId: String,
11+
val sagaId: String,
12+
val nodeName: String,
13+
val group: String,
14+
val deadLetter: String,
15+
) : AsyncRedisPubSubEvent(
1416
traceId = runCatching { MDC.get(MDCFilter.TRACE_ID) }
1517
.getOrElse { IdGenerator.generate().toString() },
1618
channel = DEAD_LETTER_OCCURRED,

src/main/kotlin/org/gitanimals/supports/deadletter/DeadLetterEventPublisher.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ class DeadLetterEventPublisher(
1717
applicationEventPublisher.publishEvent(
1818
DeadLetterEvent(
1919
deadLetterId = deadLetterId,
20-
sagaEvent = sagaEvent,
20+
sagaId = sagaEvent.id,
21+
group = sagaEvent.group,
22+
nodeName = sagaEvent.nodeName,
23+
deadLetter = sagaEvent.decodeEvent(String::class),
2124
)
2225
)
2326
}.also {

0 commit comments

Comments
 (0)