Retructured solution
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using LiteCharms.Features.Abstractions;
|
||||
|
||||
namespace LiteCharms.Features.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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user