-
-
Notifications
You must be signed in to change notification settings - Fork 803
Expand file tree
/
Copy pathOrderShippedHandler.cs
More file actions
25 lines (21 loc) · 926 Bytes
/
OrderShippedHandler.cs
File metadata and controls
25 lines (21 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using AotExample.Contracts.Events;
using AotExample.OrderService.Notifications;
using Mocha;
using Mocha.Mediator;
namespace AotExample.OrderService.Handlers;
public sealed class OrderShippedHandler(IPublisher publisher, ILogger<OrderShippedHandler> logger)
: IEventHandler<OrderShippedEvent>
{
public async ValueTask HandleAsync(OrderShippedEvent message, CancellationToken cancellationToken)
{
logger.LogOrderShipped(message.OrderId, message.TrackingNumber);
await publisher.PublishAsync(
new OrderStatusChangedNotification { OrderId = message.OrderId, Status = "Shipped" },
cancellationToken);
}
}
internal static partial class Logs
{
[LoggerMessage(Level = LogLevel.Information, Message = "Order {OrderId} shipped with tracking {TrackingNumber}")]
public static partial void LogOrderShipped(this ILogger logger, string orderId, string trackingNumber);
}