Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created June 29, 2022 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/510227c854514dd31a55b21e7847a0c6 to your computer and use it in GitHub Desktop.
Save dcomartin/510227c854514dd31a55b21e7847a0c6 to your computer and use it in GitHub Desktop.
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