【发布时间】:2013-03-04 21:49:04
【问题描述】:
我正在工作流基础 4.5 中测试接收事务范围,我认为它有问题!
查看我何时通过显式回滚来回滚事务:
using (TransactionScope s = new TransactionScope())
{
using (ServiceReference1.ServiceClient cli = new ServiceReference1.ServiceClient())
{
Transaction t = Transaction.Current;
cli.GetData(new ServiceReference1.GetData() { data = 10, ID = id });
t.Rollback();
}
}
或者通过在 transactionScope 中抛出异常:
using (TransactionScope s = new TransactionScope())
{
using (ServiceReference1.ServiceClient cli = new ServiceReference1.ServiceClient())
{
cli.GetData(new ServiceReference1.GetData() { data = 10, ID = id });
throw new Exception("Error!");
}
}
我希望工作流程也能回滚!换句话说,我希望接收“GetData”仍然有效!但这不会发生。工作流已执行,GetData 不再有效!
“GetData”后面还有其他“receives”,保证工作流不会进入“完成”状态……
我确定我的交易正在流入工作流,因为在工作流中我有一个活动会返回交易 ID(这当然与应用程序上的 ID 匹配)
谁能告诉我发生了什么?我错过了什么?
补充说明:
一切都在我的机器上运行(包括 Sql Server 2012 上的后备存储)
DTC 已启用
【问题讨论】:
标签: transactions workflow-foundation-4 transactionscope msdtc