Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active Nov 21, 2021
Embed
What would you like to do?
public async Task Process()
{
var message = default(AcknowledgeableMessage)
try
{
// Outer transaction A
var message = await GetMessage();
if (!seenMessageList.Exists(message.Id))
{
// Inner transaction B
using(var unitOfWork = new TransactionScope(...))
{
await UpdateProduct(...);
await UpdatePurchaseOrderLine(...);
await MarkEventAsSeen(...);
unitOfWork.Complete();
}
// trigger domain use case for updating recommendations
}
message.Acknowledge(); //a.k.a. transaction.Commit()
}
catch(Exception ex)
{
message.Abandon();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment