Enable Dead-Letter Queue (DLQ) in development configuration and enhance NATS consumer error handling. Update config.dev.toml to enable DLQ routing for failed messages. Modify NATS consumer to append DLQ subject to stream subjects if enabled. Improve error logging in message processing to include message IDs and DLQ routing status, ensuring better observability and error management.

This commit is contained in:
windyboy
2025-11-19 17:09:52 +08:00
parent 8914156a58
commit 5ad86d6296
4 changed files with 98 additions and 11 deletions
+4
View File
@@ -105,6 +105,10 @@ func ProvideConsumer(
if publisherSubject := strings.TrimSpace(cfg.Publisher.Topic); publisherSubject != "" {
streamSubjects = append(streamSubjects, publisherSubject)
}
// Add DLQ subject to stream if DLQ is enabled
if normCfg.dlqSubject != "" {
streamSubjects = append(streamSubjects, normCfg.dlqSubject)
}
streamSubjects = dedupeSubjects(streamSubjects)
consumer.streamManager = NewStreamManager(js, normCfg.streamName, streamSubjects, logger)