-
-
Save dcomartin/bbfe16301ddc1153bf6a09cef37eb8f6 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 PlaceOrderHandler(ILogger<PlaceOrderHandler> logger) : | |
IHandleMessages<PlaceOrder> | |
{ | |
public Task Handle(PlaceOrder message, IMessageHandlerContext context) | |
{ | |
logger.LogInformation("Received PlaceOrder, OrderId = {message.OrderId}", message.OrderId); | |
// This is normally where some business logic would occur | |
// Uncomment to test throwing a systemic exception | |
//throw new Exception("BOOM"); | |
// Uncomment to test throwing a transient exception | |
//if (Random.Shared.Next(0, 5) == 0) | |
//{ | |
// throw new Exception("Oops"); | |
//} | |
var orderPlaced = new OrderPlaced | |
{ | |
OrderId = message.OrderId | |
}; | |
return context.Publish(orderPlaced); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment