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
+23 -14
View File
@@ -86,28 +86,37 @@ public sealed class DownstreamConsumerJob(
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;
}
var (eventType, payloadJson) = outboxRow;
// Route to appropriate consumer
if (eventType == "ShadowRunCompleted")
// Route to appropriate consumer based on event type
switch (eventType)
{
var @event = JsonSerializer.Deserialize<ShadowRunCompletedEvent>(payloadJson)
?? throw new InvalidOperationException($"Failed to deserialize payload for {messageId}");
case "ShadowRunCompleted":
var shadowEvent = JsonSerializer.Deserialize<ShadowRunCompletedEvent>(payloadJson)
?? throw new InvalidOperationException($"Failed to deserialize {eventType} payload for {messageId}");
await shadowRunConsumer.HandleAsync(@event, cancellationToken);
await approvalQueueConsumer.HandleAsync(@event, cancellationToken);
await auditLogConsumer.HandleAsync(@event, cancellationToken);
await shadowRunConsumer.HandleAsync(shadowEvent, cancellationToken);
await approvalQueueConsumer.HandleAsync(shadowEvent, cancellationToken);
await auditLogConsumer.HandleAsync(shadowEvent, cancellationToken);
LogMessageProcessed(logger, messageId, eventType, null);
processedCount++;
}
else
{
logger.LogWarning("Unknown event type {EventType} for message {MessageId}", eventType, messageId);
LogMessageProcessed(logger, messageId, eventType, null);
processedCount++;
break;
case "TestEvent":
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)