开发者

Rolling back previously committed transaction

开发者 https://www.devze.com 2023-04-11 15:28 出处:网络
In the service I a开发者_JAVA百科m currently developing I need to provide a twofold operation: The request being made should be registered in the database (using Register() method); and

In the service I a开发者_JAVA百科m currently developing I need to provide a twofold operation:

  1. The request being made should be registered in the database (using Register() method); and
  2. The request should be sent to an external webservice for further processing (using Dispatch() method).

Considering that I can't switch the order of the operations, I would like to be able to "rollback" the first one if something goes wrong with the second, so that a then-invalid record does not get inserted to the BD. The problem here is that, of course, I am commiting the transaction inside the Register method. Is there any way I can roll it back from inside the Dispatch method if anything goes wrong?

Edit: All transaction are being managed from the .NET-side.


The database won't help you in this case. You have to create compensating transactions, using pairs of operations that undo each other. Your services will effectively have to replace all the work and logic that has gone into relational databases for managing transactions.

0

精彩评论

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