@oriolrius/node-red-contrib-kafka
Version:
Node-RED Kafka nodes: Send, Receive, and Schema validation with modern KafkaJS
94 lines (77 loc) • 3.88 kB
Markdown
# Kafka Schema Producer Node Status Improvements
This document outlines the improvements made to the Kafka Schema Producer node to provide better status updates similar to the regular Kafka producer node.
## Summary of Changes
### 1. Enhanced Initialization Status Updates
- **Before**: Basic "Ready" status with limited information during failures
- **After**: Step-by-step status updates showing:
- "Initializing..." when starting up
- "Connecting to Schema Registry..." during registry connection
- "Registry connected" when registry is ready
- "Connecting to Kafka..." during Kafka connection
- More descriptive error messages with partial error text
### 2. Improved Message Processing Status
- **Before**: Generic "Validating", "Sending", "Sent" statuses
- **After**: More specific status updates:
- "Validating schema" when checking/retrieving schema
- "Using cached schema" when reusing existing schema
- "Getting schema..." / "Schema retrieved" for schema operations
- "Registering schema..." when auto-registering new schemas
- "Encoding message" during message validation
- "Sending to Kafka" during actual message transmission
- "Sent successfully" → "Sent X messages" with message counter
### 3. Message Counter Integration
- Added `node.messageCount` to track total messages processed
- Status updates now show cumulative count: "Sent 5 messages"
- For validate-only mode: "Validated 3 messages"
- Counter resets on disconnect/reconnect
### 4. Enhanced Idle Status
- **Before**: Simple "Idle" status
- **After**: "Idle Xs (Y sent)" showing idle time and message count
- More informative for monitoring node activity
### 5. Better Error Reporting
- Error messages in status now show first 15 characters of actual error
- Parse errors specifically identified: "Parse error"
- Validation errors: "Validation failed"
- Connection errors show partial error details
### 6. Improved Visual Indicators
- Changed shape from "ring" to "dot" for active operations
- Consistent color coding:
- 🟡 Yellow ring: Initialization, idle states
- 🔵 Blue dot: Active operations (validating, encoding, sending)
- 🔵 Blue ring: Schema operations, getting/registering
- 🟢 Green ring: Ready state
- 🟢 Green dot: Successful completion with counters
- 🔴 Red ring: Errors with descriptive messages
## Status Flow Examples
### Successful Message Flow
1. `🟡 Initializing...`
2. `🟡 Connecting to Schema Registry...`
3. `🟡 Registry connected`
4. `🟡 Connecting to Kafka...`
5. `🟢 Ready`
6. `🔵 Validating schema` (on message)
7. `🔵 Using cached schema` (subsequent messages)
8. `🔵 Encoding message`
9. `🔵 Sending to Kafka`
10. `🟢 Sent 1 messages`
11. `🟡 Idle 6s (1 sent)` (after 5+ seconds)
### Validate-Only Mode Flow
1. `🟢 Ready`
2. `🔵 Validating schema`
3. `🔵 Encoding message`
4. `🟢 Validated 1 messages`
### Error Scenarios
- `🔴 No broker config` - No broker configured
- `🔴 Registry failed: ECONNREFUSED...` - Schema Registry connection failed
- `🔴 Kafka failed: Timeout...` - Kafka connection failed
- `🔴 Parse error` - Invalid JSON payload
- `🔴 Validation failed` - Schema validation error
- `🔴 Error: Network...` - Runtime errors
## Benefits
1. **Better Monitoring**: Users can see exactly what the node is doing at any moment
2. **Easier Debugging**: Specific error messages help identify issues quickly
3. **Performance Tracking**: Message counters show throughput over time
4. **Operational Visibility**: Clear distinction between schema operations and Kafka operations
5. **Consistency**: Matches the quality of status updates in the regular Kafka producer
## Compatibility
These changes are backward compatible and don't affect the node's functionality or API. All existing flows will continue to work as before, just with better status visibility.