开发者

How to implement two-phase commit in a .Net REST WCF service?

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 s开发者_如何学Pythonerver 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


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:

  • RETRO: A (hopefully) RESTful Transaction Model
  • Transactions are bad for REST
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜