public async Task Handle(IOrderDispatchedMessage message, IMessageHandlerContext context) { Console.WriteLine("Order has been dispatched......"); await ReplyToOriginator(context, new OrderProcessedMessage { IsSuccess = true }).ConfigureAwait(false); MarkAsComplete(); }
public void Handle(IOrderDispatchedMessage message) { Logger.InfoFormat("Order {0} has been dispatched. Notifying originator and ending saga.", Data.OrderId); ReplyToOriginator(new OrderProcessedMessage()); MarkAsComplete(); }
public async Task Handle(IOrderDispatchedMessage message, IMessageHandlerContext context) { Logger.InfoFormat("Order {0} has been dispatched. Notifying originator and ending saga.", Data.OrderId); await ReplyToOriginator(context, new OrderProcessedMessage()).ConfigureAwait(false); MarkAsComplete(); }
//Step 3: the saga receive a IOrderDispatchedMessage reply from eCommerce.Order service. //Step 4 : the saga send OrderProcessedMessage as a reply to Originator (RestApi or WebUI) and we mark itself as completed public async Task Handle(IOrderDispatchedMessage message, IMessageHandlerContext context) { logger.Info(message: $"Order {Data.OrderId} has been dispatched. Notifying originator and ending Saga..."); //When the IOrderDispatchedMessage comes back, we want to let the APPLICATION that causes saga to instantiate //KNOW that the order has been processed => so we use the ReplyToOriginator method of the saga (no routing needed!) await ReplyToOriginator(context : context, message : new OrderProcessedMessage() { AddressTo = Data.AddressTo, AddressFrom = Data.AddressFrom, Price = Data.Price, Weight = Data.Weight }) // prevent the passing in of the controls thread context into the new // thread, which we don't need for sending a message .ConfigureAwait(continueOnCapturedContext: false); //tell the saga it's done with the MarkAscomplete method //The saga will throw away the data object in the configured storage MarkAsComplete(); }