On definitive failure of the picture or audio slip, the saga now reaches a
Failed state and recovers end-to-end:
- Picture/audio track slips carry TrackId + ProcessKind variables and a
subscription to a fault translator (TrackProcessingSlipFaultConsumer) that
turns RoutingSlipFaulted into a typed Track{Picture,Audio}ProcessingFailed
- The saga stores the final object keys from the start event and, on failure,
transitions to Failed and publishes TrackProcessingFailed
- TrackProcessingFailedConsumer runs a cleanup slip that removes the orphaned
final picture/audio copies and marks the track LifeCycleStatus=Failed
(MarkTrackAsFailedActivity) — the track stays as a visible, recoverable record
- Migration for the new saga columns
Verified: Worker boots against RabbitMQ + Postgres in Docker; the new
endpoints (fault translator, failed consumer, mark-track-as-failed) configure
and the bus starts clean.
Build: 0 warnings, 0 errors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using MassTransit;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Domain.ValueObjects;
|
|
using Musify.Infrastructure.MassTransit.Arguments;
|
|
|
|
namespace Musify.Infrastructure.MassTransit.Activities.Tracks
|
|
{
|
|
internal class MarkTrackAsFailedActivity(
|
|
IDatabase database,
|
|
ILogger<MarkTrackAsFailedActivity> logger)
|
|
: IExecuteActivity<MarkTrackAsFailedArguments>
|
|
{
|
|
public const string ExecuteEndpointName = "mark-track-as-failed";
|
|
|
|
public async Task<ExecutionResult> Execute(ExecuteContext<MarkTrackAsFailedArguments> executeContext)
|
|
{
|
|
var track = await database.Tracks
|
|
.SingleOrDefaultAsync(t => t.Id == executeContext.Arguments.TrackId, executeContext.CancellationToken);
|
|
|
|
if (track is not null)
|
|
{
|
|
track.LifeCycleStatus = LifeCycleStatus.Failed;
|
|
await database.SaveChangesAsync(executeContext.CancellationToken);
|
|
logger.LogInformation("Marked track {TrackId} as failed", executeContext.Arguments.TrackId);
|
|
}
|
|
|
|
return executeContext.Completed();
|
|
}
|
|
}
|
|
}
|