views:

38

answers:

1

I'm building RESTful web service, and I want to allow it to participate in distributed transactions.

An example scenario would be that my REST service might save a file on a server somewhere, and at the same time the caller marks this file as saved in its database. However, if either the file server is full, or if his database call fails, the other action should not commit.

What can I do to keep up my side of the bargain? I'd like to find a solution that works for both .Net and Java clients. I know it's a knotty problem, I was wondering if anyone had any tips or insights? Thank you

+1  A: 

If I understand you correctly, you are talking about having multiple requests to different REST endpoints participate in a distributed transaction.

In that case you should take a look at this related question, where the answer basically says that distributed transactions is a scenario that conceptually goes against the principles of REST.

However, you could implement a solution by using the workaround explained in this answer.
You can also take a look at RETRO, which is a tentative approach to implement RESTful transactions centered around the idea of treating every element of an ACID transaction as a resource.

Related resources:

Enrico Campidoglio