Files
components/LiteCharms.Infrastructure/Quartz/MediatorJob.cs
T
Khwezi Mngoma acc0d44c7c Added abstractions
Internal service bus support enabled
Added quartz support
Reconfigured extensions
2026-05-07 16:08:47 +02:00

22 lines
641 B
C#

using LiteCharms.Abstractions;
namespace LiteCharms.Infrastructure.Quartz;
[DisallowConcurrentExecution]
public class MediatorJob<TNotification>(IMediator mediator) : IJob where TNotification : IEvent
{
public async Task Execute(IJobExecutionContext context)
{
var data = context.MergedJobDataMap["Payload"] as string;
if (string.IsNullOrWhiteSpace(data)) return;
var notification = JsonSerializer.Deserialize<TNotification>(data);
if(notification is null) return;
if(notification is TNotification)
await mediator.Publish(notification, context.CancellationToken);
}
}