回滚之前提交的事务
在我当前正在开发的服务中,我需要提供双重操作:
- 发出的请求应该在数据库中注册(使用
Register()
方法);并且 - 请求应发送到外部网络服务以进行进一步处理(使用
Dispatch()
方法)。
考虑到我无法切换操作的顺序,如果第二个操作出现问题,我希望能够“回滚”第一个操作,这样当时无效的记录就不会插入到 BD 中。当然,这里的问题是我在 Register
方法内提交事务。如果出现问题,有什么方法可以从 Dispatch
方法内部将其回滚吗?
编辑:所有事务都是从.NET 端管理的。
In the service I am currently developing I need to provide a twofold operation:
- The request being made should be registered in the database (using
Register()
method); and - 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,数据库将无法帮助您。您必须使用相互撤销的成对操作来创建补偿事务。您的服务将有效地取代关系数据库中用于管理事务的所有工作和逻辑。
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.