Retructured solution
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using LiteCharms.Features.Abstractions;
|
||||
using LiteCharms.Features.ServiceBus.Queues;
|
||||
|
||||
namespace LiteCharms.Features.ServiceBus.Exchanges;
|
||||
|
||||
public class EmailExchange(EmailQueue messages, ILogger<EmailExchange> logger, IPublisher mediator) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await foreach(IEvent? message in messages.Incoming.ReadAllAsync(stoppingToken))
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (message.Name)
|
||||
{
|
||||
case "SendShopEmailEnquiryEvent":
|
||||
await mediator.Publish(message, stoppingToken);
|
||||
break;
|
||||
case "ProcessEmailNotificationsEvent":
|
||||
await mediator.Publish(message, stoppingToken);
|
||||
break;
|
||||
default:
|
||||
logger.LogWarning("Unsupported email event {Event}", message.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using LiteCharms.Features.ServiceBus.Queues;
|
||||
|
||||
namespace LiteCharms.Features.ServiceBus.Exchanges;
|
||||
|
||||
public class GeneralExchange(GeneralQueue messages) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
if (messages.Incoming.CanCount)
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using LiteCharms.Features.ServiceBus.Queues;
|
||||
|
||||
namespace LiteCharms.Features.ServiceBus.Exchanges;
|
||||
|
||||
public class SalesExchange(SalesQueue messages) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
if (messages.Incoming.CanCount)
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user