Phase 7.1: Implement Error Handling and Message Acknowledgment (#103)#146
Merged
Phase 7.1: Implement Error Handling and Message Acknowledgment (#103)#146
Conversation
- Add ErrorClassifier for exception categorization - Add ErrorClassification model with ErrorCode, IsRetryable, ShouldRequeue, Severity - Add ErrorSeverity enum (Warning, Error, Critical) - Implement pattern matching for common exception types - Add default handler for unknown exceptions
- Add Dead Letter Exchange (stargate.processes.dlx) configuration - Add Dead Letter Queue (stargate.processes.dead-letter) setup - Configure main queue with x-dead-letter-exchange arguments - Implement retry count tracking in message headers (x-retry-count) - Add poison message detection (max 5 retries) - Auto-move poison messages to DLQ - Enhanced logging for retry tracking and DLX operations - Update EnsureQueueExists to create and bind DLX topology
- Replace simple exception type checking with ErrorClassifier - Use error classification for ACK/NACK decisions - Record error classification details in process failure - Add comprehensive logging with classification metadata - Implement Decision Matrix for error handling: * Malformed messages: NACK without requeue -> DLQ * Retryable errors: NACK with requeue * Non-retryable errors: NACK without requeue -> DLQ - Enhanced error reporting with ErrorCode and Severity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Overview
Implements comprehensive error handling and message acknowledgment strategy for ProcessWorker to ensure reliable message processing, proper error classification, correct ACK/NACK behavior, and integration with dead-letter queues.
Closes #103
🎯 Implemented Features
1. Error Classification System
ErrorClassifierwith pattern matching for exception categorizationErrorClassificationmodel with ErrorCode, IsRetryable, ShouldRequeue, SeverityErrorSeverityenum (Warning, Error, Critical)2. Dead Letter Exchange Configuration
stargate.processes.dlx(topic, durable)stargate.processes.dead-letter(durable)#x-dead-letter-exchangearguments3. Poison Message Detection
x-retry-countheader4. ProcessWorker Integration
📊 ACK/NACK Decision Matrix
🧪 Testing
Unit Tests
All tests passing:
Integration Testing Instructions
Verify RabbitMQ topology:
docker-compose up -d rabbitmq open http://localhost:15672 # Login: guest/guestExpected exchanges:
stargate.processes(main)stargate.processes.dlx(dead-letter)Expected queues:
stargate.processes(with DLX config)stargate.processes.dead-letterTest malformed message:
Test poison message:
Monitor DLQ:
stargate.processes.dead-letterqueue📝 Technical Details
Error Classification Logic
The
ErrorClassifieruses pattern matching to map exceptions to classification:Dead Letter Exchange Flow
Poison Message Protection
🔄 Changes Summary
New Files
src/StarGate.Core/Errors/ErrorClassifier.cstests/StarGate.Core.Tests/Errors/ErrorClassifierTests.csModified Files
src/StarGate.Infrastructure/Messaging/RabbitMQ/RabbitMqConsumer.cssrc/StarGate.Server/Workers/ProcessWorker.cs✅ Checklist
📚 References
🏷️ Labels
phase-7process-enginesprint-7.1error-handling⏱️ Effort
Actual: ~8 hours (aligned with estimate)
🔗 Dependencies