4.6 Two orders, one T-shirt
The concurrency check turns a lost race into a DbUpdateConcurrencyException. Running the same
order again would read the new stock and could succeed, so it is a transient failure.
Failures/ShopfrontFailureClassifier.cs:
using Microsoft.EntityFrameworkCore;
using Trax.Core.Exceptions;
using Trax.Effect.Services.FailureClassifier;
namespace Shopfront.Failures;
public class ShopfrontFailureClassifier : IFailureClassifier
{
public FailureClass? Classify(Exception exception) =>
exception switch
{
// A message for the customer: the same order fails the same way however often it runs.
TrainException => FailureClass.Permanent,
// The provider did not answer this time; it may next time.
TimeoutException => FailureClass.Transient,
// Another order changed the stock first; trying again reads the new stock.
DbUpdateConcurrencyException => FailureClass.Transient,
_ => null,
};
}SDK Reference
DomainDataContext | EnsureSchemaCreatedAsync | Add a domain data context | IFailureClassifier | Architecture guards