public Task Handle(BillingRecordCreated message, IMessageHandlerContext context) { Log.Info($"Received {nameof(BillingRecordCreated)} event/message"); Data.BillingRecordCreated = true; // return Task.CompletedTask; return(ProcessOrder(context)); }
// EVENT handler, not COMMAND handler - implementation-wise there's no difference. public async Task Handle(OrderCreated message, IMessageHandlerContext context) { Log.Info($"Received {nameof(OrderCreated)}, OrderId = {message.OrderId} - preparing for billing activities."); try { var billingRecord = new BillingRecordCreated { BillingRecordId = Guid.NewGuid().ToString(), OrderId = message.OrderId, CreatedOn = message.CreatedOn, CreatedBy = message.CreatedBy }; await context.Publish(billingRecord); } catch (Exception e) { Console.WriteLine(e); throw; } }