Alex Rivera | Logout

Patterns for implementing transactions outside of a database

Asked 2009-02-24T03:09:11.533
9

I have to send an email, write to a file, and call a web service. To maintain consistency, all steps must happen. If any step throws an exception or errors out, all steps must be rolled back.

Before I go rolling my own object ACID engine, are there any commonly accepted patterns for implementing ACID semantics at the object level?

Better yet, are there any existing libraries I can use for the the .NET platform?

Edit: I know sending an email can't be undone, but failing to connect to the SMTP server is cause to kill the whole transaction. Also, I'd like this to be extensible for use with future actions.

Edit
Report

1 Answer

3

Windows Workflow Foundation has a concept of compensation (using Composite activity) when ACID semantics might not be appropriate..Off course, it has support for ACID transactions as well.

A good question is why bother with compensation? Isn’t one big ACID transaction with automatic rollback just as good? An ACID transaction is most appropriate when operations occur within the same database or within the same information system. It is also most appropriate when operations end quickly. When different companies and services are involved, defining the process in terms of the ACID semantics is often challenging. For it to be isolated and durable, you have to keep all resources of different companies locked for the duration of the task. This is frequently unreasonable, especially if the task is long. For it to be consistent and atomic, you need ad hoc compensation code.

answered 2009-02-24T03:18:56.533

Your Answer