前两笔交易成功但第三笔交易失败,如何回滚操作 [英] How Do I Rollback Operation If First Two Transaction Occurs Successfully But Third Transaction Cannot Be Successful

查看:164
本文介绍了前两笔交易成功但第三笔交易失败,如何回滚操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发.net应用程序,其中要一次性执行三个操作.首先,将记录插入表中,然后将第一封邮件发送给admin,将第二封邮件发送给填写表单的用户..我不确定如何成功执行这三个操作.如果前两个操作已完成,而最后一个操作无法完成,则必须回滚.我正在考虑使用事务来执行此操作,并在任何操作未完成的情况下使用try catch异常回滚.但是我的疑问是,是否插入了记录并发送了第一封邮件,而在第二封邮件发送中发生了邮件发送失败,是第一封邮件发送回滚了 !!!

I am developing .net application where in three operations are to be performed at one go. At first, record is to be inserted into table, then first mail is to be send to admin and second mail is to be send to user who fills form.. I am not sure as to how can these three operations can be performed successfully. If first two operations are completed and last operation is not able to complete, then it must rollback. I am thinking of using transaction to do so and roll back using try catch exception if any of the operation is not complete. But my doubt is if record is inserted and first mail is send and mail send failure occurs in second mail send, is the first mail send rollbacked !!! is there another method to do so???

推荐答案

显然,已发送的邮件无法撤消,这超出了交易范围.但是,您可以通过回滚过程中的失败通知另一封邮件通知管理员.
Apparently, mail that was sent cannot be undone, that is beyond the scope of transaction. However, you can notify the admin through another mail about the failure during rollback.


不幸的是,您无法取消发送电子邮件.我建议您搜索可以将电子邮件排队的第三方产品,也许可以使用它,或者在其中一封电子邮件失败时添加通知功能.
Unfortunately you cannot unsend the email message. I suggest you search for a 3rd party product that can queue emails and perhaps use that or instead add a notification feature if one of the emails fails.


这篇关于前两笔交易成功但第三笔交易失败,如何回滚操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆