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 PlaceOrderSaga : | |
Saga<PlaceOrderSagaData>, | |
IAmStartedByMessages<OrderPlaced>, | |
IHandleMessages<OrderBilled>, | |
IHandleMessages<ShippingLabelCreated> | |
{ | |
protected override void ConfigureHowToFindSaga(SagaPropertyMapper<PlaceOrderSagaData> mapper) | |
{ | |
mapper.MapSaga(saga => saga.OrderId) | |
.ToMessage<OrderPlaced>(msg => msg.OrderId) | |
.ToMessage<OrderBilled>(msg => msg.OrderId) | |
.ToMessage<ShippingLabelCreated>(msg => msg.OrderId); | |
} | |
public async Task Handle(OrderPlaced message, IMessageHandlerContext context) | |
{ | |
await context.Send(new BillOrder | |
{ | |
OrderId = message.OrderId | |
}); | |
} | |
public async Task Handle(OrderBilled message, IMessageHandlerContext context) | |
{ | |
await context.Send(new CreateShippingLabel | |
{ | |
OrderId = message.OrderId | |
}); | |
} | |
public async Task Handle(ShippingLabelCreated message, IMessageHandlerContext context) | |
{ | |
await context.Send(new ReadyToShipOrder | |
{ | |
OrderId = Data.OrderId | |
}); | |
MarkAsComplete(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment