消息队列的 TransactionScope 问题
我面临下一个问题。我有一段代码,如下所示:
DoSomething(){
using (TransactionScope scope = new TransactionScope())
{
InsertSomething();
InsertSomethingElse();
InsertYetAnotherThing();
ProcessDataRelatedWithThePreviousInserts();
scope.Complete()
}
}
在 ProcessDataRelatedWithThePreviousInserts 中,我检查条件,如果需要,其余的工作流程将重定向到其他服务器中的消息队列。在另一台服务器中,我恢复消息,并继续工作流程(基本上,进行一些与 DoSomething 方法上的插入相关的其他插入)。
这是理论上的,因为只有在 DoSomething 方法中删除 TransactionScope 时,我才能做到这一点。有没有办法完成我想做的事情,或者我需要改变交易的处理方式?
I'm facing the next problem. I have a piece of code that goes like this:
DoSomething(){
using (TransactionScope scope = new TransactionScope())
{
InsertSomething();
InsertSomethingElse();
InsertYetAnotherThing();
ProcessDataRelatedWithThePreviousInserts();
scope.Complete()
}
}
In ProcessDataRelatedWithThePreviousInserts I check for a condition and if needed, the rest of the work flow is redirected to a Message Queue in other server. In the other server, I recover the message, and continue the workflow (basically, make some other insertions that are related with the ones on the DoSomething method).
This is in theory, because I only manage to do that if I remove the TransactionScope in the DoSomething method. Is there a way to accomplish what I want to do or I'll need to change the way the transactions are handled?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已尝试
显式抑制调用 ProcessDataRelatedWithThePreviousInserts() 的外部事务。
Did you already try
explicitly supressing the outer transaction for your call to ProcessDataRelatedWithThePreviousInserts().