Replace ~240 lines of hand-written per-endpoint wiring with MassTransit's ConfigureEndpoints + KebabCaseEndpointNameFormatter, and apply retry + EF outbox globally through AddConfigureEndpointsCallback. Adding a consumer or activity is now a single AddConsumer/AddActivity line. - Normalize the 4 mismatched activity endpoint names to kebab-case so the routing-slip addressing keeps resolving (update-play-list-picture, delete/mark/publish play-list variants); cleanup consumer queue is now routing-slip-clean-up - Drop the now-unused QueueName consts from event consumers and trim EndpointHelper / delete the manual endpoint-config partial Verified end-to-end: booted the Worker against RabbitMQ in Docker and confirmed all 38 endpoints are configured with the exact names the builders address (19 execute queues + compensations + consumers + routing-slip-clean-up). Build: 0 warnings, 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using MassTransit;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Infrastructure.MassTransit.Arguments;
|
|
|
|
namespace Musify.Infrastructure.MassTransit.Activities.PlayLists
|
|
{
|
|
internal class DeletePlayListFromDbActivity(
|
|
IDatabase database,
|
|
ILogger<DeletePlayListFromDbActivity> logger)
|
|
: IExecuteActivity<DeletePlayListFromDbArguments>
|
|
{
|
|
public const string ExecuteEndpointName = "delete-play-list-from-db";
|
|
|
|
public async Task<ExecutionResult> Execute(ExecuteContext<DeletePlayListFromDbArguments> executeContext)
|
|
{
|
|
var playList = await database.PlayLists
|
|
.SingleOrDefaultAsync(p => p.Id == executeContext.Arguments.PlayListId, executeContext.CancellationToken);
|
|
|
|
if (playList is null)
|
|
{
|
|
logger.LogInformation(
|
|
"PlayList {PlayListId} not found while deleting from DB, skipping",
|
|
executeContext.Arguments.PlayListId);
|
|
return executeContext.Completed();
|
|
}
|
|
|
|
database.PlayLists.Remove(playList);
|
|
await database.SaveChangesAsync(executeContext.CancellationToken);
|
|
|
|
logger.LogInformation("Deleted playlist {PlayListId} from DB", playList.Id);
|
|
return executeContext.Completed();
|
|
}
|
|
}
|
|
}
|