Skip to content

Commit 6893db6

Browse files
authored
release: 1.4.4 (#154)
2 parents 279a716 + 4c5d62b commit 6893db6

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class SlackDeadLetterMessageListener(
3434
"clicked" to "RELAY",
3535
"sourceKey" to "RELAY_DEAD_LETTER",
3636
"approveToken" to approveToken,
37-
"deadLetterId" to deadLetterEvent.deadLetterId
37+
"deadLetterId" to deadLetterEvent.deadLetterId,
38+
"nodeName" to deadLetterEvent.nodeName,
3839
)
3940

4041
notification.notifyWithActions(

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class DeadLetterRelayEventListener(
2020
private val deadLetterRelay: DeadLetterRelay,
2121
private val applicationEventPublisher: ApplicationEventPublisher,
2222
@Value("\${relay.approve.token}") private val approveToken: String,
23+
@Value("\${netx.node-name}") private val nodeName: String,
2324
) : TraceableMessageListener(redisTemplate, objectMapper) {
2425

2526
private val logger = LoggerFactory.getLogger(this::class.simpleName)
@@ -42,8 +43,9 @@ class DeadLetterRelayEventListener(
4243

4344
val approveToken = payload["approveToken"] as String
4445
val deadLetterId = payload["deadLetterId"] as String
46+
val nodeName = payload["nodeName"] as String
4547

46-
if (approveToken != this.approveToken) {
48+
if (approveToken != this.approveToken || nodeName != this.nodeName) {
4749
return
4850
}
4951

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.gitanimals.supports.deadletter
2+
3+
import org.gitanimals.core.TraceIdContextOrchestrator
4+
import org.gitanimals.core.TraceIdContextRollback
5+
import org.gitanimals.core.filter.MDCFilter.Companion.TRACE_ID
6+
import org.rooftop.netx.api.OrchestratorFactory
7+
import org.slf4j.MDC
8+
import org.springframework.web.bind.annotation.GetMapping
9+
import org.springframework.web.bind.annotation.RequestParam
10+
import org.springframework.web.bind.annotation.RestController
11+
12+
@RestController
13+
class DeadLetterTestController(
14+
private val deadLetterEventPublisher: DeadLetterEventPublisher,
15+
private val orchestratorFactory: OrchestratorFactory,
16+
) {
17+
18+
@GetMapping("/test/dead-letter")
19+
fun test(
20+
@RequestParam("message") message: String,
21+
) {
22+
val orchestrator = orchestratorFactory.create<String>("dead-letter-test")
23+
.startWithContext(
24+
contextOrchestrate = TraceIdContextOrchestrator { _, it -> it },
25+
contextRollback = TraceIdContextRollback { _, it ->
26+
it
27+
}
28+
)
29+
.joinWithContext(
30+
contextOrchestrate = TraceIdContextOrchestrator { _, it -> it },
31+
contextRollback = TraceIdContextRollback { _, it ->
32+
throw IllegalStateException("add dead letter")
33+
}
34+
)
35+
.commitWithContext(TraceIdContextOrchestrator { _, _ ->
36+
throw IllegalStateException("test dead-letter")
37+
})
38+
39+
val result = orchestrator.sagaSync(message, context = mapOf("hello" to "world", "traceId" to MDC.get(TRACE_ID)))
40+
41+
if (result.isSuccess.not()) {
42+
result.throwError()
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)