femto-backend/Femto.Modules.Auth/Infrastructure/OutboxMessageHandler.cs
2025-05-17 23:47:19 +02:00

22 lines
694 B
C#

using Femto.Common.Infrastructure.Outbox;
using Femto.Common.Integration;
using Microsoft.Extensions.Logging;
namespace Femto.Modules.Auth.Infrastructure;
public class OutboxMessageHandler(IEventPublisher publisher, ILogger<OutboxMessageHandler> logger) : IOutboxMessageHandler
{
public async Task HandleMessage<TNotification>(
TNotification notification,
CancellationToken executionContextCancellationToken
)
{
if (notification is IEvent evt)
{
await publisher.Publish(evt);
} else
{
logger.LogWarning("ignoring non IEvent {Type} in outbox message handler", typeof(TNotification));
}
}
}