我正面临下一个问题。我有一段代码是这样的:
DoSomething(){
using (TransactionScope scope = new TransactionScope())
{
InsertSomething();
InsertSomethingElse();
InsertYetAnotherThing();
ProcessDataRelatedWithThePreviousInserts();
scope.Complete()
}
}
在 ProcessDataRelatedWithThePreviousInserts 我检查一个条件,如果需要,工作流的其余部分被重定向到其他服务器中的消息队列。在另一台服务器中,我恢复消息,并继续工作流程(基本上,进行一些与 DoSomething 方法相关的其他插入)。
这是理论上的,因为我只有在 DoSomething 方法中删除 TransactionScope 时才能做到这一点。有没有办法完成我想做的事情,或者我需要改变交易的处理方式?