-
-
Save dcomartin/510227c854514dd31a55b21e7847a0c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReserveOrderHandler : IHandleMessages<ReserveOrder> | |
{ | |
private readonly Reservation _reservation; | |
public ReserveOrderHandler(Reservation reservation) | |
{ | |
_reservation = reservation; | |
} | |
public async Task Handle(ReserveOrder message, IMessageHandlerContext context) | |
{ | |
if (_reservation.Reserve(message.OrderId)) | |
{ | |
var expireOptions = new SendOptions(); | |
expireOptions.DelayDeliveryWith(TimeSpan.FromDays(7)); | |
await context.Send(new ExpireReservation { OrderId = message.OrderId }, expireOptions); | |
await context.Publish(new OrderReserved { OrderId = message.OrderId }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment