improvement: Enhance DownstreamConsumerJob logging - handle legacy events, suppress false warnings
ci / backend (push) Failing after 1s
ci / static (push) Failing after 6s
ci / frontend (push) Failing after 41s

This commit is contained in:
2026-08-02 23:21:22 +09:00
parent e2488cdcfa
commit c2e21677c5
+21 -12
View File
@@ -86,28 +86,37 @@ public sealed class DownstreamConsumerJob(
if (outboxRow == default) if (outboxRow == default)
{ {
logger.LogWarning("Outbox message {MessageId} not found; skipping", messageId); logger.LogInformation("Outbox message {MessageId} not found; skipping (may be expired or deleted)", messageId);
continue; continue;
} }
var (eventType, payloadJson) = outboxRow; var (eventType, payloadJson) = outboxRow;
// Route to appropriate consumer // Route to appropriate consumer based on event type
if (eventType == "ShadowRunCompleted") switch (eventType)
{ {
var @event = JsonSerializer.Deserialize<ShadowRunCompletedEvent>(payloadJson) case "ShadowRunCompleted":
?? throw new InvalidOperationException($"Failed to deserialize payload for {messageId}"); var shadowEvent = JsonSerializer.Deserialize<ShadowRunCompletedEvent>(payloadJson)
?? throw new InvalidOperationException($"Failed to deserialize {eventType} payload for {messageId}");
await shadowRunConsumer.HandleAsync(@event, cancellationToken); await shadowRunConsumer.HandleAsync(shadowEvent, cancellationToken);
await approvalQueueConsumer.HandleAsync(@event, cancellationToken); await approvalQueueConsumer.HandleAsync(shadowEvent, cancellationToken);
await auditLogConsumer.HandleAsync(@event, cancellationToken); await auditLogConsumer.HandleAsync(shadowEvent, cancellationToken);
LogMessageProcessed(logger, messageId, eventType, null); LogMessageProcessed(logger, messageId, eventType, null);
processedCount++; processedCount++;
} break;
else
{ case "TestEvent":
logger.LogWarning("Unknown event type {EventType} for message {MessageId}", eventType, messageId); case "OldEvent":
case "RecentEvent":
// Legacy/test events - log as debug and skip
logger.LogDebug("Skipping legacy/test event type {EventType} for message {MessageId}", eventType, messageId);
break;
default:
logger.LogInformation("Unsupported event type {EventType} for message {MessageId} (not yet implemented)", eventType, messageId);
break;
} }
} }
catch (Exception ex) catch (Exception ex)